Individuals with autism spectrum disorder (ASD) often show limited empathy (poor recognition of others’ emotions) and high alexithymia (poor recognition of own emotions and external thinking), which can negatively impact their social functioning. Previous experimental studies suggest that alterations in cognitive flexibility play key roles in the development of these characteristics in ASD. However, the underlying neural mechanisms that link cognitive flexibility and empathy/alexithymia are still largely unknown. In this study, we examined the neural correlates of cognitive flexibility via functional magnetic resonance imaging during perceptual task-switching in typical development (TD) adults and adults with ASD. We also investigated associations between regional neural activity and psychometric empathy and alexithymia scores among these populations. In the TD group, stronger activation of the left middle frontal gyrus was associated with better perceptual switching and greater empathic concern. Among individuals with ASD, stronger activation of the left inferior frontal gyrus was associated with better perceptual switching, greater empathy, and lower alexithymia. These findings will contribute to develop a better understanding of social cognition, and could be informative for the development of new ASD therapies.Copyright © 2023 Elsevier Ltd. All rights reserved.