Cognitive abilities related to the assessment of risk improve survival. While earlier studies have examined the ability of animals to learn to avoid predators, learned parasite avoidance has received little interest. In a series of behavioural trials with the trematode parasite Diplostomum pseudospathaceum, we asked whether sea trout (Salmo trutta trutta) hosts show associative learning in the context of parasitism and if so, whether learning capacity is related to the likelihood of infection mediated through host personality and resistance. We show that animals are capable of learning to avoid visual cues associated with the presence of parasites. However, avoidance behaviour ceased after the likely activation of host resistance following consecutive exposures during learning, suggesting that resistance to infection outweighs avoidance. Further, we found a positive relationship between learning ability and boldness, suggesting a compensation of risky lifestyles through increased investment in cognitive abilities. By contrast, an increased risk of infection due to low resistance was not balanced by learning ability. Instead, these traits were positively related, which may be explained by inherent physiological qualities controlling both traits. Overall, the results demonstrate that parasitism, in addition to other biological interactions such as predation, is an important selective factor in the evolution of animal cognition.