The heart is a highly specialized organ with essential function for the organism throughout life. The significance of DNA methylation in shaping the phenotype of the heart remains only partially known. Here we generate and analyse DNA methylomes from highly purified cardiomyocytes of neonatal, adult healthy and adult failing hearts. We identify large genomic regions that are differentially methylated during cardiomyocyte development and maturation. Demethylation of cardiomyocyte gene bodies correlates strongly with increased gene expression. Silencing of demethylated genes is characterized by the polycomb mark H3K27me3 or by DNA methylation. De novo methylation by DNA methyltransferases 3A/B causes repression of fetal cardiac genes, including essential components of the cardiac sarcomere. Failing cardiomyocytes partially resemble neonatal methylation patterns. This study establishes DNA methylation as a highly dynamic process during postnatal growth of cardiomyocytes and their adaptation to pathological stress in a process tightly linked to gene regulation and activity.