This same thing just happened to Pete last night

. He was humping his pleasure pooch for a few minutes then laid down and was resting, I went over to him about an hour later to hold him and noticed it was still halfway out! It had never stayed out that long before about 45 minutes later I decided to try and help it, we have some sterile lubricant in the house so I put a dab on and gently. . . well maybe thats too much info but whatever I did it seemed to help, within about 15 minutes it was back where it should be. I too was planning on taking Pete to the vet if it didnt go back, I read it can be very painful and also causes infections if its out too long. Needless to say his pleasure pooch (by the way not a name I gave it, its what the tag says!) is on a permanent time out I dont need that happening again!
Im glad to hear your little man is doing ok, he certainly did not look happy in that photo.