My son is going through the same thing,i took him too the doctors and his foreskin wont go back properly,they have give us cream for a month to help him,but if it is no better he has to be circumsized.
I would have him checked by a doctor, just in case. Is he circumcised? If not, is he cleaning under his foreskin thoroughly and drying it? Is he changing his underwear daily? Does he sweat a lot? Wear an athletic supporter? Plays sports?
(my background always causes me to suspect sexual abuse anytime a child has an issue with their privates...so that was my first thought, that something is happening and he doesn't know how to tell...but that is MY bias...)
Could be some irritation is he using the bathroom okay , does it hurt when he urinates? or maybe its rubbing on his pants ,some vaseline or soothing cream he can put on may help ,if its inflamed get it checked out for infection ..good luck