I had this problem often, and eventually realized that it was becuase the condoms were two small for my girth. Not only did this make for tight and uncomfortable fit, but I needed a lot of fumbling to get them on, and often "lost the moment" during my frustrating efforts to get the condom on. However, I was already using one of the widest condoms available over the counter (Magnum XL).
Then I found the They Fit Condoms (available from Condomania.com), thanks to LPSG. The They Fit size U22 fits like a glove, yet goes on easily, and I no longer loose erection. Although they cost twice as much as the Trojan Magnum XL I used before, and have to be mail-ordered, the They Fit Condoms are well worth the cost and effort.
So, make sure your condoms fit correctly. A condom should be tight enough not to slip off, but not so tight that it is hard to put on or difficult to remove. With the U22 size, I find it is not too constricting, but is snug enough that there is no way it will ever pull off. In fact, even if I go soft afterwards, the the only way I can get them off is to roll them inside out.