I would first make sure an infection isn't present. That would include a urinalysis and a genprobe looking for gonorrhea and chlamydia.
If that is negative, then tests for prostate and scrotal infections can be considered (i.e. with a digital rectal exam and possible scrotal ultrasound looking for epididymitis).
Anatomical abnormalities such as urethral strictures or polyps can also cause pain, and this can be evaluated by a cystoscopy.
In any case, I would suggest a referral to a urologist.
Followup with your personal physician is essential.
This answer is not intended as and does not substitute for medical advice - the information presented is for patient education only. Please see your personal physician for further evaluation of your individual case.
Thanks,
Kevin, M.D.