Why does it hurt to pee when I'm on my period?

Infection vs none. If it's a usual event and resolves with resolution of the period then it is not infection. It would be consistent with dysmenorrhea i.e. Pain during period due to irritation of the pelvic area due to a variety of reasons among which endometriosis, minute uterine lining tissue sitting outside/on the bladder area and gets irritated during the period where contraction of bladder will cause it to hurt.