The history of stimuli and rewards in the recent past drives an automatic form of attention in animals and humans in which attentional priority is given to previously rewarded stimuli. The neurobiological basis for this form of attention is unknown. In a novel whisker touch detection task, we show that mice flexibly shift attention between specific whiskers, based on the recent history of stimulus-reward association. 2-photon calcium imaging and spike recordings revealed a robust neurobiological correlate in somatosensory cortex (S1), involving topographically precise, whisker-specific boosting of L2/3 pyramidal (PYR) cell sensory responses to attended whiskers, and receptive fields shift towards attended whiskers. L2/3 VIP interneurons were activated by whisker stimuli, motion and arousal but did not carry a whisker-specific attentional signal, so do not mediate this form of attention. Thus, reward history drives attentional capture that is associated with dynamic, topographically precise modulation of sensory-evoked activity in S1.