Vertebrates gut microbial communities can be altered by the hosts parasites. Helminths inhabiting the gut lumen can interact directly with their hosts microbiota via physical contact, chemical products, or competition for nutrients. Indirect interactions can also occur, for instance when helminths induce or suppress host immunity in ways that have collateral effects on the microbiota. If there is genetic variation in host immune responses to parasites, we would expect such indirect effects to be conditional on host genotype. To test for such genotype by infection interactions, we experimentally exposed Gasterosteus aculeatus to their naturally co-evolved parasite, Schistocephalus solidus. The host microbiota differed in response to parasite exposure, and between infected and uninfected fish. The magnitude and direction of microbial responses to infection differed between host sexes, and also differed between variants at autosomal quantitative trait loci. These results indicate that host genotype and sex regulate the effect of helminth infection on a vertebrate gut microbiota. If this result holds in other taxa, especially humans, then helminth-based therapeutics for dysbiosis might need to be tailored to host genotype and sex.