Epigenetic modifications of DNA regulate gene expression throughout the lifespan in neurons. Two major epigenetic pathways of repression, DNA methylation and Polycomb repressive complex 2 (PRC2) mediated gene silencing, regulate neuronal physiology and function, but their relative contributions are unknown. We found that conditional loss of the de novo DNA methyltransferase Dnmt3a in mouse excitatory neurons altered expression of synapse-related genes, impaired the maturation of postsynaptic dendritic spines and dampened neuronal excitability. These phenotypes were accompanied by working memory and social interest deficits. To elucidate the epigenetic mechanisms, we performed deep sequencing of DNA methylation, transcription, and chromatin modifications in cortical excitatory neurons. Loss of Dnmt3a abolished postnatal accumulation of CG and non-CG DNA methylation, leaving neurons with an unmethylated, fetal-like epigenomic pattern at ~140,000 genomic regions. The PRC2 associated histone modification H3K27me3 increased at many of these sites, partially compensating for the loss of DNA methylation. Our results suggest a complex interaction between two key modes of epigenetic repression of gene expression during brain development that supports cognitive function in adulthood.