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 pulled apart effects of distraction and cognitive control on pain by delivering noxious stimulations During or After (factor TIMING) a Stroop paradigm (requiring high cognitive load) or a neutral condition (factor TASK). We found that TIMING influenced subjective pain experience, with less intense and unpleasant ratings During task execution. This hypoalgesia was associated with enhanced activity at the level of the dorsolateral prefrontal cortex and the posterior parietal cortex, in interaction 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.