During development, progenitor cells with binary potential give rise to daughter cells that have distinct functions. Heritable epigenetic mechanisms then lock in gene-expression programs that define lineage identity. Regulation of the gene encoding the T cell-specific coreceptor CD4 in helper and cytotoxic T cells exemplifies this process, with enhancer- and silencer-regulated establishment of epigenetic memory for stable gene expression and repression, respectively. Using a genetic screen, we identified the DNA-methylation machinery as essential for maintaining silencing of Cd4 in the cytotoxic lineage. Furthermore, we found a requirement for the proximal enhancer in mediating the removal of DNA-methylation marks from Cd4, which allowed stable expression of Cd4 in helper T cells. Our findings suggest that stage-specific methylation and demethylation events in Cd4 regulate its heritable expression in response to the distinct signals that dictate lineage 'choice' during T cell development.