In most animals, female investment in offspring production is greater than for males. Lifetime reproductive success (LRS) is predicted to be optimized in females through extended lifespans to maximize reproductive events by increased investment in immunity. Males, however, maximize lifetime reproductive success by obtaining as many matings as possible. In populations consisting of mainly hermaphrodites, optimization of reproductive success may be primarily influenced by gamete and resource availability. Microbe-mediated protection (MMP) is known to affect both immunity and reproduction, but whether sex influences the response to MMP remains to be explored. Here, we investigated the sex-specific differences in survival, behavior, and timing of offspring production between feminized hermaphrodite (female) and male Caenorhabditis elegans following pathogenic infection with Staphylococcus aureus with or without MMP by Enterococcus faecalis. Overall, female survival decreased with increased mating. With MMP, females increased investment into offspring production, while males displayed higher behavioral activity. MMP was furthermore able to dampen costs that females experience due to mating with males. These results demonstrate that strategies employed under pathogen infection with and without MMP are sex dependent.