I'm going to assume that you have been masturbating by touching the outside genitalia.
If you're not careful and touch/ rub your urethra instead of just your clitoris, you can get bacteria into the urethra, causing a urinary tract infection. One of the symptoms of a urinary tract infections is painful urination. Are you sure your bladder hurts and not the area where the urine comes out? If you do have a UTI, you can take AZO/ cranberry extract pills or drink lots of cranberry juice and water to flush it out of your system. In the future, make sure your hands are clean and try to steer clear of the urethra, which is below the clitoris.
Also, don't be embarassed if you have a UTI. All women get one at some time or another and it is not caused by only masturbation.