need more specific details on when and how you're losing wood. if you are perfectly healthy then it might be in your head. i remember a short period in my younger years where i had lotsa issues staying hard with this particular girl and it was all in my head. i was so perplexed with being able to perform in bed that it actually got to me mentally and my dick shut down.
i was afraid to get or stay "hard" as it was safer than getting hard and not doing a good job at it. in short, if the dick was hard then that means i didn't have to put out therefore no chance of embarrassment (even if not getting it up wasn't bad enough). she also made fun of me too so that didn't help either.
long story short, we broke up after a short relationship and i hooked up with a side chick that was totally cool with any performance and was able to relieve me of my anxiety and it was great. i got my dick back and fucked away without any worry. if i came too soon, she was totally cool and just asked me to finger her or eat her out til she came. she didn't care how she came as long as she came and i was willing to help. it was awesome. plenty of times i was able to fuck her to orgasm too. i guess once the pressure was off, i could be myself and let go.
as the other have said, go get checked out just in case by a doctor; but it could also be in your head too...