There is mounting evidence that pathogen threat affects social preferences and responses. In humans, the presence of strangers also elicits heightened sensitivity to pathogen threat, promoting ‘in-group’ bias and ‘out-group’ avoidance. Whether or not a similar effect of social context on responses to pathogen threat occurs in nonhuman animals is unclear. Here we show that the responses of female laboratory mice, Mus muculus, to males are also rapidly affected by the presence of unfamiliar or infected males. In female mice, where odour cues drive appetitive and aversive social responses, brief (1 min) exposure to the urinary odours of an unfamiliar male led to females subsequently discriminating more strongly against the odours of males subclinically infected with the murine nematode parasite, Heligmosomoides polygyrus. Likewise, brief exposure to the odours of infected males attenuated the responses of females to the odours of the normally preferred unfamiliar males and enhanced their preferences for familiar males. These findings are consistent with the concept of ‘assortative’ sociality, whereby the presence of pathogen threat and unfamiliar individuals biases female preferences for uninfected and familiar individuals (‘in-group’ preference and, in human terms, ‘ethnocentrism’) and leads to the avoidance of unfamiliar individuals (‘out-group’ avoidance and ‘xenophobia’). Hence, as in humans, social information associated with infection can rapidly bias the social preferences of female mice. These rapid shifts in social preferences can have implications for our understanding of the evolution of social interactions and group composition.