Mythimna separata (Lepidoptera: Noctuidae) is an omnivorous pest that poses a great threat to food security. Insect antimicrobial peptides (AMPs) are small peptides that are important effector molecules of innate immunity. Here, we investigated the role of the AMP cecropin B in the growth, development, and immunity of M. separata. The gene encoding M. separata cecropin B (MscecropinB) was cloned. The expression of MscecropinB was determined in different developmental stages and tissues of M. separata. It was highest in the prepupal stage, followed by the pupal stage. Among larval stages, the highest expression was observed in the fourth instar. Tissue expression analysis of fourth instar larvae showed that MscecropinB was highly expressed in the fat body and haemolymph. An increase in population density led to upregulation of MscecropinB expression. MscecropinB expression was also upregulated by the infection of third and fourth instar M. separata with Beauveria bassiana or Bacillus thuringiensis (Bt). RNA interference (RNAi) targeting MscecropinB inhibited the emergence rate and fecundity of M. separata, and resulted in an increased sensitivity to B. bassiana and Bt. The mortality of M. separata larvae was significantly higher in pathogen plus RNAi-treated M. separata than in controls treated with pathogens only. Our findings indicate that MscecropinB functions in the eclosion and fecundity of M. separata and plays an important role in resistance to infection by B. bassiana and Bt.