First, try to relax. More often than many realize, an erection problem can be directly linked to stress. If you are constantly stressed and worried about not being able to obtain an erection or stay erect for long enough, then it is going to compound the problem.
Enjoy the moment and try not to worry about it. Just focus on your own enjoyment, and work at pleasing your partner. Often when you recognize that your partner is enjoying themselves, it will help you to relax and gain a better erection. Usually the woman does not even require penetration to achieve an orgasm, and this will help you build up to a climax. Take it slow and enjoy it.
Try having sex at various times of the day. Some men may find that they can achieve a better erection more easily at a certain time of day. Stay healthy and fit, take vitamins, and do your best to stay active. These factors will all help.
If you really are concerned that you have a premature ejaculation problem or erectile dysfunction, you should probably consult a doctor. These are professionals and can offer some valuable insight and advice. If it is discovered that you do have an issue, also make your partner aware of this. It is nothing to be ashamed of, and having your partner aware of the issue will help you both.