Pancreatic β cells secrete insulin in response to postprandial increases in glucose levels to prevent hyperglycemia and inhibit insulin secretion under fasting conditions to protect against hypoglycemia. β cells lack this functional capability at birth and acquire glucose-stimulated insulin secretion (GSIS) during neonatal life. Here, we have shown that during postnatal life, the de novo DNA methyltransferase DNMT3A initiates a metabolic program by repressing key genes, thereby enabling the coupling of insulin secretion to glucose levels. In a murine model, β cell-specific deletion of Dnmt3a prevented the metabolic switch, resulting in loss of GSIS. DNMT3A bound to the promoters of the genes encoding hexokinase 1 (HK1) and lactate dehydrogenase A (LDHA) - both of which regulate the metabolic switch - and knockdown of these two key DNMT3A targets restored the GSIS response in islets from animals with β cell-specific Dnmt3a deletion. Furthermore, DNA methylation-mediated repression of glucose-secretion decoupling genes to modulate GSIS was conserved in human β cells. Together, our results reveal a role for DNA methylation to direct the acquisition of pancreatic β cell function.