The neural circuits underlying goal-directed sensorimotor transformations in the mammalian brain are incompletely understood. Here, we compared the role of primary tongue-jaw motor cortex (tjM1) and primary whisker sensory cortex (wS1) in head-restrained mice trained to lick a reward spout in response to whisker deflection. Two-photon microscopy combined with microprisms allowed imaging of neuronal network activity across cortical layers in transgenic mice expressing a genetically encoded calcium indicator. Early-phase activity in wS1 encoded the whisker sensory stimulus and was necessary for detection of whisker stimuli. Activity in tjM1 encoded licking direction during task execution and was necessary for contralateral licking. Pre-stimulus activity in tjM1, but not wS1, was predictive of lick direction and contributed causally to small preparatory jaw movements. Our data reveal a shift in coding scheme from wS1 to tjM1, consistent with the hypothesis that these areas represent cortical start and end points for this goal-directed sensorimotor transformation.