The innate immunity of insects has been widely studied. Although the effect of sex on insect immunity has been extensively discussed, differences in immunity between the sexes of larvae insects remain largely unstudied. Studying larval sex differences in immunity may provide valuable information about the mechanisms underlying the insect immune system, which, in turn, can be valuable for the development and improvement of pest management. Here we compared the antibacterial activity in both the midgut tissue and cell-free hemolymph of Lymantria dispar L. (Lepidoptera: Erebidae) females and males at the larval stage without and after a challenge by entomopathogenic bacterium Bacillus thuringiensis Berliner. We also evaluated the sex-specific mortality of L. dispar induced by B. thuringiensis infection. We find that antibacterial activity in the midgut is activated by infection, but only in females. Thus, sex differences in immunity can have important effects even before sexual differentiation at adulthood.