Host resistance and parasite virulence are influenced by multiple interacting factors in complex natural communities. Yet, these interactive effects are seldom studied concurrently, resulting in poor understanding of host-pathogen-environment dynamics. Here, we investigated how the level of opportunist pathogen virulence, strength of host immunity and the host condition manipulated via diet affect the survival of wood tiger moth Parasemia plantaginis (Arctidae). Larvae from “low cuticular melanin” and “high cuticular melanin” (considered as low and high pathogen resistance, respectively) selection lines were infected with moderately and highly virulent bacteria strains of Serratia marcescens, while simultaneously manipulating host diet (with or without antibacterial compounds). We measured host survival and food preference before and after infection to test whether the larvae “self-medicate” by choosing an anti-infection diet (Plantago major, i.e., plantain leaf) over lettuce (Lactuca sativa). “High melanin” larvae were more resistant than “low melanin” larvae to the less virulent strain that had slower growth and colonization rate compared with the more virulent strain. Cuticular melanin did not enhance survival when the larvae were infected with the highly virulent strain. Anti-infection diet enhanced survival of the “high melanin” but not the “low melanin” hosts. Survival was dependent on family origin even within the melanin selection lines. Despite the intrinsic preference for lettuce, no evidence of self-medication was found. These results demonstrate that the relative benefit of host cuticular melanin depends on both diet and pathogen virulence: plantain diet only boosted the immunity of already resistant “high melanin” hosts, and cuticular melanin increased host survival only when infected with moderately virulent pathogen. Moreover, there was considerable variation in host survival between families within both melanin lines suggesting genetic basis for resistance. These results indicate that although melanin is an important predictor of insect immunity, its effect on disease outcomes greatly depends on other interacting factors.