In many organisms, host-associated microbial communities are acquired horizontally after birth. This process is believed to be shaped by a combination of environmental and host genetic factors. We examined whether genetic variation in animal behavior could affect the composition of the animal's microbiota in different environments. The freshwater crustacean Daphnia magna is primarily planktonic but exhibits variation in the degree to which it browses in benthic sediments. We performed an experiment with clonal lines of D. magna showing different levels of sediment-browsing intensity exposed to either bacteria-rich or bacteria-poor sediment or whose access to sediments was prevented. We found that the bacterial composition of the environment and genotype-specific browsing intensity together influence the composition of the Daphnia-associated bacterial community. Exposure to more diverse bacteria did not lead to a more diverse microbiome, but greater abundances of environment-specific bacteria were found associated with host genotypes that exhibited greater browsing behavior. Our results indicate that, although there is a great deal of variation between individuals, behavior can mediate genotype-by-environment interaction effects on microbiome composition. IMPORTANCE An animal's behavior can affect its risk of infection, but it is not well understood how behavior affects microbiome composition. The aquatic crustacean Daphnia exhibits genetic variation in the extent to which it browses in the sediment at the bottoms of ponds. We show that this behavior affects the Daphnia microbiome, indicating that genetic variation among individuals may affect microbiome composition and the movement of bacteria in different environments.