Myelination of the central nervous system requires the generation of functionally mature oligodendrocytes from oligodendrocyte precursor cells (OPCs). Electrically active neurons may influence OPC function and selectively instruct myelination of an active neural circuit. In this work, we use optogenetic stimulation of the premotor cortex in awake, behaving mice to demonstrate that neuronal activity elicits a mitogenic response of neural progenitor cells and OPCs, promotes oligodendrogenesis, and increases myelination within the deep layers of the premotor cortex and subcortical white matter. We further show that this neuronal activity-regulated oligodendrogenesis and myelination is associated with improved motor function of the corresponding limb. Oligodendrogenesis and myelination appear necessary for the observed functional improvement, as epigenetic blockade of oligodendrocyte differentiation and myelin changes prevents the activity-regulated behavioral improvement.