I've had exactly the same problem. The thing is to take it easy. It's all in your head, and when you are afraid of it it happends. Relax, and admit to yourself that it doesn't matter if it really happends sometimes. For me it helped when I discussed about it with my girlfriend.
You know erection happends mostly because of your mind and thoughts. Doctors
have said always that problem with erection is almost always because of psychic reasons. RELAX mate! You'll overcome it. Happends to me time to time still, and also my other mental problem; premature ejaculation. But what the heck, that's life so stop worrying and RELAX!