The microbial community composition is crucial for diverse life-history traits in many organisms. However, we still lack a sufficient understanding of how the host microbiome is acquired and maintained, a pressing issue in times of global environmental change. Here we investigated to what extent host genotype, environmental conditions, and the endosymbiont Wolbachia influence the bacterial communities in the parasitic wasp Asobara japonica. We sampled multiple wasp populations across 10 locations in their natural distribution range in Japan and sequenced the host genome (whole genome sequencing) and microbiome (16S rRNA gene). We compared the host population structure and bacterial community composition of wasps that reproduce sexually and are uninfected with Wolbachia with wasps that reproduce asexually and carry Wolbachia. The bacterial communities in asexual wasps were highly similar due to a strong effect of Wolbachia rather than host genomic structure. In contrast, in sexual wasps, bacterial communities appear primarily shaped by a combination of population structure and environmental conditions. Our research highlights that multiple factors shape the bacterial communities of an organism and that the presence of a single endosymbiont can strongly alter their compositions. This information is crucial to understanding how organisms and their associated microbiome will react in the face of environmental change.