You are mostly suffering from urinary tract infection
. Here, you need to undergo one urine examination (microscopic & culture) to confirm the diagnosis.
Proper antibiotic therapy like norfloxacin/ ofloxacin
etc for 5-7 days along with urine alkaliser can eliminate this type of problem. Consult with your doctor regarding this.
In addition, you should follow some measurable steps like drink plenty of water/ fluids (3 lit plus/ day), take cranberry juice, eat low protein balanced diet with more vegetables, maintain genital hygiene with proper shaving & cleaning, empty bladder in 3-4 hrs interval, wear only clean & cotton underwear.
Be well and practice protected sex in future.