In the human somatosensory system, the contralateral primary somatosensory cortex (SI) is presumed to process and encode type and intensity of the sensory inputs, whereas the bilateral secondary somatosensory cortex (SII) is believed to perform higher order functions including sensorimotor integration, integration of information from the two body halves, attention, learning and memory. In this fMRI study we investigated the effect of attention on the activation of SI and SII, as induced by nonpainful and painful rare deviant electric stimuli during somatosensory oddball tasks. The working hypothesis is of stronger effects of attention on SII with respect to SI. Four runs were acquired according to an oddball scheme. Frequent nonpainful electrical stimuli were delivered to the ulnar nerve at motor threshold, whereas rare/deviant stimuli were delivered to median nerve in four conditions (one condition per run): nonpainful, painful, counting nonpainful, and counting painful. Results showed a statistically significant fMRI activation in bilateral SII but not in contralateral SI when the rare/deviant median nerve stimuli were delivered at nonpainful and painful levels as well as at the two levels of attention considered (i.e., associated with counting and non-counting tasks). Furthermore, fMRI activation in SII did not differ across the different levels of stimulus intensity (nonpainful, painful) and attention (non-counting, counting). These results corroborate the notion that SII is the target of independent pathways for the processing and integration of nonpainful and painful somatosensory stimuli salient for further high-order elaborations.