The incidence of chronic pain is especially high in women, but the underlying mechanisms remain poorly understood. Interleukin-23 (IL-23) is a pro-inflammatory cytokine and contributes to inflammatory diseases (e.g., arthritis and psoriasis) through dendritic/T cell signaling. Here we examined the IL-23 involvement in sexual dimorphism of pain, using an optogenetic approach in transgenic mice expressing channelrhodopsin-2 (ChR2) in TRPV1-positive nociceptive neurons. In situ hybridization revealed that compared to males, females had a significantly larger portion of small-sized (100-200 μm2) Trpv1+ neurons in dorsal root ganglion (DRG). Blue light stimulation of a hindpaw of transgenic mice induced intensity-dependent spontaneous pain. At the highest intensity, females showed more intense spontaneous pain than males. Intraplantar injection of IL-23 (100 ng) induced mechanical allodynia in females only but had no effects on paw edema. Furthermore, intraplantar IL-23 only potentiated blue light-induced pain in females, and intrathecal injection of IL-23 also potentiated low-dose capsaicin (500 ng) induced spontaneous pain in females but not males. IL-23 expresses in DRG macrophages of both sexes. Intrathecal injection of IL-23 induced significantly greater p38 phosphorylation (p-p38), a marker of nociceptor activation, in DRGs of female mice than male mice. In THP-1 human macrophages estrogen and chemotherapy co-application increased IL-23 secretion, and furthermore, estrogen and IL-23 co-application, but not estrogen and IL-23 alone, significantly increased IL-17A release. These findings suggest a novel role of IL-23 in macrophage signaling and female-dominant pain, including C-fiber-mediated spontaneous pain. Our study has also provided new insight into cytokine-mediated macrophage-nociceptor interactions, in a sex-dependent manner.