Microorganisms symbiotic with insects, whether permanently or temporarily, play a crucial role in the nutrition, development, reproduction, defence, and metamorphosis regulation. In some Lepidoptera, oviposition-deterrent pheromones (ODPs) on egg surface were used by pregnant females to modify the behaviour of conspecifics to avoid excessive competition for limited resources. In this study, we constructed four different Spodoptera litura groups, including, OH, OA, SH, and OA, which either feed on different hosts or grow in different environments. The 16S rDNA libraries of microbes from the egg surface of the four groups were constructed and sequenced. According to alpha and beta diversity indices, the microbes in environments and diets considerably influenced the richness, diversity, and community compositions of the microbiota on egg surfaces. The quantity of the main ODP components and the corresponding oviposition-deterrent activity among four groups were significantly differed among the four groups. The result of this study revealed that altering of microbes in environments or diets considerably changed the contents of ODP and oviposition-deterrent activity. As ODPs impart oviposition-deterrent activity towards closely related species, the findings of this study suggest that we should pay more attention to the role of symbiotic microorganisms in changing the ability of insects, especially sympatric species, to occupy the optimal niche when developing novel pest-control strategies.