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.
Endometriosis. One possibility is that you may have endometriosis. If you have this condition, there may be implants of tissue from the lining of your uterus that are on your bladder. When you are on your period, they bleed and become inflamed, causing painful urination. You should also be evaluated for a UTI.