I've posted this before a few times, but see if this sounds familiar...
My 4 year old went through something that sounds much like this just a couple of months ago.
Turned out to be separation starting. There was a large lump under his foreskin on one side -- enough to look pretty scary -- and he cried a little that it hurt. When he'd urinate, it would swell even further and he said it stung.
I plunked him in a warm bath and he quickly forgot about it although it was still swollen. A couple of hours after the bath, I noticed a very odd odor coming from him, and sure enough, there was a pretty sizeable amount of tan-colored stuff in his underwear.
Turns out that this is classic separation trauma. As the foreskin separates from the glans, it doesn't always do so evenly, and this forms little pockets where smegma (normal sloughed skin cells) can form into little balls -- sometimes called "pearls" -- that are between the glans and the foreskin. When he urinated, the urine collected there, too, and then when the urine drained out, it washed the smegma with it.
This went on for a couple of days, then it cleared up completely. His foreskin still balloons when he urinates, sometimes, but he hasn't had another "pearl" or swelling.
If this sounds like what your son is experiencing, I'd just suggest lots of time in a warm bath and lots of hugs. I told my son that it was just like getting his grown-up teeth. Sometimes there's some discomfort involved, but it's just all part of the growing up process.
Hope some of that helps!