Flexible integration of sensory information in a context-dependent manner is a key cognitive process required to generate appropriate behavior. An intriguing question, then, is how the same sensory stimulus can be interpreted differently according to context in order to generate different behavioral responses. In this thesis, I aimed at identifying the cortical circuits responsible for context-dependent sensorimotor transformation. I designed a task in which thirsty head-restrained mice were trained to lick for a water reward in response to a brief single whisker stimulus if it was preceded by a brief Go-tone presented one second before the whisker stimulus, but not if it was preceded by a NoGo-tone. I used focal optogenetic inactivation to identify cortical areas causally involved in different task epochs. I found that inactivation of primary whisker somatosensory cortex (wS1), secondary whisker somatosensory cortex (wS2), secondary whisker motor cortex (wM2), or anterior lateral motor cortex (ALM) during the presentation of the whisker stimulus strongly decreased the probability of licking in the reward window in Gotrials. Inactivation of wM2 and ALM during the delay between the Go-tone and the whisker stimulus also strongly reduced licking in the reward window. I recorded neuronal activity in auditory cortex (A1), wS1, wS2, wM2, and ALM using multiple Neuropixels probes simultaneously. Prominent persistent activity following the Gotone presentation was found selectively in wM2 and ALM, even in trials devoid of delay period movements. Using linear decoding of neuronal activity, we found that the accuracy of classifying context in the 200 ms before the whisker stimulus was significantly higher than the baseline chance level, with the highest accuracy in wM2 and ALM. Temporal correlation analysis showed that the contextual information was maintained in frontal areas through stable persistent activity. Consistently, it was possible to classify context with high accuracy from the neuronal activity of wM2 and ALM, throughout the delay period, using a classifier trained only on the last 200 ms of the delay period. These findings suggest a crucial role for the frontal areas wM2 and ALM in the encoding and maintenance of contextual information in a short-term memory task. I hypothesise that wM2 might gate the transformation of whisker sensory information into motor action in a context-dependent manner. Sensory information from wS1 and wS2 might be signalled through long-range projection neurons directly innervating wM2. The incoming sensory information might then trigger different neuronal activity dynamics in wM2 depending upon its pre-whisker stimulus initial contextdependent state. In the Go context, this triggers a licking response, while in the Nogo context, the same whisker stimulus does not initiate licking. Overall, our findings highlight a critical role for the frontal regions ALM and wM2 in maintaining context through stable neuronal states,