We studied the effects of inflammatory pain on working memory and correlated the pain effects with changes in dendritic spine density and glutamate signaling in the medial prefrontal cortex (mPFC) of male and female mice. Injection of Complete Freund's Adjuvant (CFA) into the hind paw modeled inflammatory pain. The CFA equally decreased the mechanical thresholds in both sexes. The density of dendritic spines, as a marker for neuronal input, increased on the dendrites of both, pyramidal cells and interneurons in males but only on the dendrites of interneurons in CFA injected females. Next, we injected virus with glutamate sensor (pAAV.hSyn.iGluSnFr) into the mPFC and used fiber photometry to record glutamate signaling during Y-maze spontaneous alternations test, which is a test for working memory in rodents. The detected fluorescent signal was higher during correct alternations when compared to incorrect alternations in both sexes. The CFA injection did not change the pattern of glutamate fluorescence during the test but the female mice made fewer incorrect alternations than their male counterparts. Furthermore, while the CFA injection decreased the expression of the glutamate transporter VGlut1 on the soma of mPFC neurons in both sexes, the decrease was sex dependent. We concluded that inflammatory pain, which increases sensory input into the mPFC neurons, may impair working memory by altering the glutamate signaling. The glutamate deficit that develops as a result of the pain is more pronounced in male mice in comparison to female mice.