It has been generally thought that sex differences in the immune system are the result of the differing life history strategies of the sexes, although the available data are not entirely consistent with the hypothesis. In this study, we studied the variation in the immune function in the mound-building wood ant Formica exsecta. F. exsecta has two forms of males, distinguished by size: the small males (micraners) and the large males (macraners), which die after the mating period, whereas females live tens of years laying their eggs. We found that in general males have a lower encapsulation response against nylon monofilament (i.e. lower immune function) than queens. Among males, the micraners had a lower encapsulation rate than the macraners. However, in queens, there was no correlation between size and encapsulation rate. The origin nest had an effect on the encapsulation rate of males: males from the large nests had a stronger encapsulation rate than males from small nests. However, in queens, nest size did not have any effect on encapsulation response. The observed variation between sexes and individuals in the encapsulation rate is discussed in the context of reproductive strategies and parasite-mediated sexual selection.