Postinflammatory irritable bowel syndrome (PI-IBS) is a common functional gastrointestinal disorder, which is characterized by abdominal pain, low-grade inflammation, and visceral hypersensitivity. Shaoyao-Gancao decoction (SGD) has been used to improve the clinical symptoms of abdominal spasmodic pain accompanying acute gastroenteritis, but the underlying therapeutic mechanism has not been fully elucidated. In the present study, a rat model of PI-IBS was established via rectal administration of TNBS. Rats were scored daily for 28 days using disease activity index (DAI). Abdominal withdrawal reflex (AWR) was used to measure the pain threshold. After SGD (6.25, 12.5, and 25 g/kg/d) treatment for 14 days, rat colonic tissue was collected for histopathological grading, enterochromaffin (EC) cell count, and 5-HT content measurement. RT-qPCR and western blot analyses were employed to detect the gene and protein level of tryptophan hydroxylase (TPH), serotonin reuptake transporter (SERT), and transient receptor potential vanilloid 1 (TRPV1). To further validate the effect of SGD on TRPV1, another experiment was performed in cells. The results revealed that visceral hyperalgesia, reflected by increased DAI, AWR, pathological injury score, 5-HT content, and EC cell count in PI-IBS rats, was significantly ameliorated by SGD. In cells, SGD markedly inhibited the expression and function of TRPV1. Moreover, the expression levels of TPH were also repressed by SGD. The findings of the present study indicated that the therapeutic effect of SGD on visceral hyperalgesia may be closely associated with the regulatory role of TRPV1 and 5-HT signaling pathways.