Upper part of penis becomes swollen only while urination
What do you mean by upper part?
If you are not circumcised, do you pull your foreskin back when you pee? If not, it may be your foreskin filling up with urine like a balloon.