Did you try to pull the sheath of skin around it? Maybe its stuck. He may have been humping something and now just needs some help getting it back in. If you try to move the skin around it, that sometimes helps. I'm not sure how to describe the action.
If its really not going back in, then you'll want to get him checked out by vet.