What if you ask him what's up?
The majority of the time people are doing something, it has nothing to do with you. Could be him reacting to something going on in his life.
It could be that he was conditioned to act this way. People learn how to act from past relationships, not always the healthy lessons.
It's possible that he was to eager in a past relationship, which turned the other guy off. Now when things are going good, he plays it cool to try to keep you from getting turned off by his eagerness.
He could have gotten hurt in a past relationship. The cold shoulder is to keep you two from getting to close and to keep him from getting hurt.
It's all speculation at this point. If you like him and want to continue going out with him, tell him how when things are going well you tend to experience a cold shoulder from him. Communication is key to clearing up your issues.
If he gets defensive or isn't able to talk to you, then maybe you cut your losses and move on.