Cognitive abilities decline in normal aging, yet the underlying molecular mechanisms are poorly understood. We found that aging was associated with a decrease in the expression of the DNA methyltransferase Dnmt3a2 in the hippocampus and that rescuing Dnmt3a2 levels restored cognitive functions. Moreover, we found that Dnmt3a2 is an activity-regulated immediate early gene that is partly dependent on nuclear calcium signaling and that hippocampal Dnmt3a2 levels determine cognitive abilities in both young adult and aged mice.