In the mammalian neocortex, segregated processing streams are thought to be important for forming sensory representations of the environment, but how local information in primary sensory cortex is transmitted to other distant cortical areas during behaviour is unclear. Here we show task-dependent activation of distinct, largely non-overlapping long-range projection neurons in the whisker region of primary somatosensory cortex (S1) in awake, behaving mice. Using two-photon calcium imaging, we monitored neuronal activity in anatomically identified S1 neurons projecting to secondary somatosensory (S2) or primary motor (M1) cortex in mice using their whiskers to perform a texture-discrimination task or a task that required them to detect the presence of an object at a certain location. Whisking-related cells were found among S2-projecting (S2P) but not M1-projecting (M1P) neurons. A higher fraction of S2P than M1P neurons showed touch-related responses during texture discrimination, whereas a higher fraction of M1P than S2P neurons showed touch-related responses during the detection task. In both tasks, S2P and M1P neurons could discriminate similarly between trials producing different behavioural decisions. However, in trials producing the same decision, S2P neurons performed better at discriminating texture, whereas M1P neurons were better at discriminating location. Sensory stimulus features alone were not sufficient to elicit these differences, suggesting that selective transmission of S1 information to S2 and M1 is driven by behaviour.