Previous studies found that distracting someone through a challenging activity leads to hypoalgesia, an effect mediated by parietal and prefrontal processes. Other studies suggest that challenging activities affect the ability to regulate one’s aching experiences, due to partially-common neural substrate between cognitive control and pain at the level the medial prefrontal cortex. We investigated effects of distraction and cognitive control on pain by delivering noxious stimulations during or after a Stroop paradigm (requiring high cognitive load) or a neutral condition. We found less intense and unpleasant subjective pain ratings during (compared to after) task execution. This hypoalgesia was associated with enhanced activity at the level of the dorsolateral prefrontal cortex and the posterior parietal cortex, which also showed negative connectivity with the insula. Furthermore, multivariate pattern analysis revealed that distraction altered the neural response to pain, by making it more similar to that associated with previous Stroop tasks. All these effects were independent of the nature of the task which, instead, led to a localized neural modulation around the anterior cingulate cortex. Overall, our study underscores the role played by two facets of human executive functions, which exert independent influence in the neural response of pain.