The symbiotic bacteria–insect interaction is considered to be associated with immunity and drug resistance. However, the wide variety of insect species and habitats is thought to have a significant impact on the symbiotic community, leading to disparate results. Here, we demonstrated that symbiotic bacteria regulated the immune response by changing the proportion of the Gram-positive and the Gram-negative bacterial community in Lymantria dispar (L. dispar) after infection with its viral pathogen, L. dispar Nucleopolyhedrovirus (LdMNPV). After oral infection, the immune deficiency pathway was activated immediately, and the expression of Relish was up-regulated to promote the secretion of antimicrobial peptides. Meanwhile, the abundance of the Gram-negative bacterial community increased at the same time. Moreover, the Toll pathway was not regulated in the same way as the Imd pathway was after infection. However, the change in the Toll pathway’s expression remained positively correlated to the abundance of Gram-positive bacteria. This finding implied that the ratio of Gram-negative to Gram-positive bacteria in the LdMNPV infected larvae had an effect on the immune response. Our findings revealed that the immune regulation of L. dispar was regulated by the relative abundance of its symbiotic bacteria at different infection times with LdMNPV, which provides a new way to understand symbiotic bacteria–insect interactions.