The classical cognitive-behavioral theory of obsessive-compulsive disorder (OCD) holds that compulsions are performed to reduce distress that is evoked by obsessions, whereas a recent neuroscience-inspired theory suggests that compulsivity results from a disbalance between goal-directed and habit-related neural networks. To bridge these theories, we investigated whether the balance between goal-directed and habit networks in patients with OCD was affected during psychological distress. Twenty-three OCD patients and twenty-three healthy controls participated in a controlled stress induction paradigm using the socially evaluated cold-pressor test in a crossover design. Stress responses were evaluated through cortisol levels, blood pressure, and anxiety ratings. Functional connectivity of the caudate nucleus and posterior putamen was assessed using seed region analysis of resting-state functional magnetic resonance imaging data, which are hubs of the goal-directed and habit network, respectively. Stress induction increased blood pressure and psychological stress measures across groups and resulted in blunted cortisol responses in patients. Furthermore, patients showed a blunted reduction in connectivity between the caudate nucleus and precuneus during psychological distress, which was positively correlated with compulsivity but not obsession severity. The posterior putamen showed no significant group differences in distress-induced connectivity. These results suggest that compulsivity in OCD is associated with altered connectivity between the goal-directed and default mode networks during psychological distress.