I know this is an old thread, but since it was brought back to life...
This is called Paraphimosis.
Sometimes it will retract on it's own after awhile, BUT if you're dog is like that for more than 6hrs is can be dangerous as the tip of his "lipstick" can dry out and the circulation can become cut off and kill it. Resulting in a full castration.
Had this happen to one of my dogs, and it was like that for 12hrs and that's what the vet told me, plus if you google it there's tons of info.