As parasites coevolve with their hosts, they can evolve counter-defenses that render host immune responses ineffective. These counter-defenses are more likely to evolve in specialist parasites than generalist parasites; the latter face variable selection pressures between the different hosts they infect. Natural populations of the fruit fly Drosophila melanogaster are commonly threatened by endoparasitoid wasps in the genus Leptopilina, including the specialist L. boulardi and the generalist L. heterotoma, and both wasp species can incapacitate the cellular immune response of D. melanogaster larvae. Given that ethanol tolerance is high in D. melanogaster and stronger in the specialist wasp than the generalist, we tested whether fly larvae could use ethanol as an anti-parasite defense and whether its effectiveness would differ against the two wasp species. We found that fly larvae benefited from eating ethanol-containing food during exposure to L. heterotoma; we observed a two-fold decrease in parasitization intensity and a 24-fold increase in fly survival to adulthood. Although host ethanol consumption did not affect L. boulardi parasitization rates or intensities, it led to a modest increase in fly survival. Thus, ethanol conferred stronger protection against the generalist wasp than the specialist. We tested whether fly larvae can self-medicate by seeking ethanol-containing food after being attacked by wasps, but found no support for this hypothesis. We also allowed female flies to choose between control and ethanol-containing oviposition sites in the presence vs. absence of wasps and generally found significant preferences for ethanol regardless of wasp presence. Overall, our results suggest that D. melanogaster larvae obtain protection from certain parasitoid wasp species through their mothers' innate oviposition preferences for ethanol-containing food sources.