There are two things here. The first is very probably a mind thing - confronted with a condom, something is going 'eek' and you're losing your erection. Am I right in reading your post as saying that you're using another form of contraception, so sometimes have sex without? Is there a problem maintaining then?
The second just needs some practice. You need to learn what the signs are that you're about to come and then, if you don't want to do so just then, doing something to delay that. How quickly do you come when you masturbate?
It's at this point that I highly recommend Bernie Zilbergeld's book, which contains plenty to think about and exercises for both erection issues and coming quicker than you'd like. In the UK, the first edition is known as 'Men and Sex'; in the US it was 'Male Sexuality' and hence the title of the second edition was 'The New Male Sexuality'. Amazon invariably has at least one listing for at least one of them available for 1p+postage second-hand.