This sounds like what my son went though when his foreskin began separating. When the foreskin starts separating the urine can pass under the foreskin and sting quite a bite. The swelling is just the foreskin reacting to the truama of separation. My son was in a great deal of pain for a couple days until the glans smoothed over and the urine no longer stung the glans. It is probably worse at night and in the morning when the urine is more concentrated. If you see him urinate you might even notice some ballooning which is just the pee going under the foreskin. This is nothing to worry about.
Until the foreskin separates entirely he might go through phases of stinging as more areas are knocked loose and the fresh glans are exposed. Once the entire foreskin is separated it will not sting anymore.
That swelling you see on one side is probably the side where the urine is passing underneath. Foreskin is very vascular so it reacts when there is a trauma associated with separation.
I highly doubt this is a UTI b/c it doesn't happen every time and you didn't indicate that he has any fever or frequent urination. If you take him to the doctor you need to be very careful no one tries to retract him for any reason!
Please read these two threads:
http://www.mothering.com/discussions...893&highlight=http://www.mothering.com/discussions....php?t=764732?
I'd say that about 97% of these cases we see on here are just symptoms of normal separation. Your doctor will not be likely to know about the symptoms of normal separation so you might cause more problems by going than if you just give it a couple days. My son's case was pretty extreme b/c his entire foreskin came loose all at once when he was 10 months old. He screamed in pain when he urinated and he had some pretty significant swelling. I was very worried but in about 3-4 days everything passed. Now he has a nice balloon when he pees but the glans have smoothed over. Ballooning is actually a good thing b/c it rinses out the dead skin cells when he urinates. Urine is sterile so you don't have to worry about it causing any infection.

Please feel free pm me if you have further questions.
Follow Mothering