I am able to masturbate but unable to maintain erection while having sex with a woman. Why?

Probably psychologic. You are in complete control when you masturbate. You try some counseling, or else consider medication such as viagra (sildenafil) or cialis. Good luck.