TH17 cells exemplify environmental immune adaptation: they can acquire both a pathogenic and an anti-inflammatory fate. However, it is not known whether the anti-inflammatory fate is merely a vestigial trait, or whether it serves to preserve the integrity of the host tissues. Here we show that the capacity of TH17 cells to acquire an anti-inflammatory fate is necessary to sustain immunological tolerance, yet it impairs immune protection against S. aureus. Additionally, we find that TGF-β signalling via Smad3/Smad4 is sufficient for the expression of the anti-inflammatory cytokine, IL-10, in TH17 cells. Our data thus indicate a key function of TH17 cell plasticity in maintaining immune homeostasis, and dissect the molecular mechanisms explaining the functional flexibility of TH17 cells with regard to environmental changes.