Is your member inflamed, itchy or redder in color that usual. If it is it it sound like you have Balanitis.
Balanitis is caused by poor hygiene, skin irritation (IE, a change in detergents, soaps, shower gels and fabric of your underwear)
Potential irritants to avoid
If you have balanitis, urine is the most important irritant to keep away from the skin of your penis. Other irritants to avoid include:
soap and shower gel
If you are experiencing soreness, itching, stinging or redness, start using a steriod based cream or anti-fungal cream.
In other cases it could be a bacterial infection. They way to treat this is to use anti-bacterial soap free wash and rinse with plenty of clean water (do not over wash or use to much friction).
And when having sex and masturbating. Do not pump to hard as it will be extremely painful, go at your own pace and do what is comfortable for you.
Your frenum could be super sensitive. In my own experience, mine has actually bleed while having sex, and was painful afterwards. Try not to be to hard in sexual activity, because this could happen.
Hope i have helped you in some way. Hope you problem gets sorted and wish you a speedy recovery and good health. Take care.