Arynne has some good advice for you. This is because your conscious mind can only focus on one task at a time - and if you are wondering how long your penis is going to stay hard, then you are no longer focused on the activities which will naturally make you hard!
It is common for a man to lose erection hardness while he is giving foreplay to his partner. This is because when you are focused on the 'mechanics' of your fingers and tongue moving to pleasure your partner, you cannot simultaneously be enjoying the feelings in your penis (which is one of the things which makes you hard).
I think a lot of your difficulties may be arising from performance anxiety or simply watching yourself to see if you get an erection or not. This scrambles the subconscious messages trying to communicate with your penis. If you take intercourse off the menu for a while and when you have an erection let your girlfriend come on top and do all the work for you while you just lie there and do nothing. No performance on anxiety.