A cognitive task, the n-back task, was used to interrogate the cognitive dimension of pain in patients with implanted dorsal root ganglion stimulators (DRGS). Magnetoencephalography (MEG) signals from thirteen patients with implanted DRGS were recorded at rest and while performing the n-back task at three increasing working memory loads with DRGS-OFF and the task repeated with DRGS-ON. MEG recordings were pre-processed, then power spectral analysis and source localization were conducted. DRGS resulted in a significant reduction in reported pain scores (mean 23%, p = 0.001) and gamma oscillatory activity (p = 0.036) during task performance. DRGS-induced pain relief also resulted in a significantly reduced reaction time during high working memory load (p = 0.011). A significant increase in average gamma power was observed during task performance compared to the resting state. However, patients who reported exacerbations of pain demonstrated a significantly elevated gamma power (F(3,80) = 65.011612, p < 0.001, adjusted p-value = 0.01), compared to those who reported pain relief during the task. Our findings demonstrate that gamma oscillatory activity is differentially modulated by cognitive load in the presence of pain, and this activity is predominantly localized to the prefrontal and anterior cingulate cortices in a chronic pain cohort.