hello and welcome to healthcare forum.
From your complain it seems that you are having tight attachment of your foreskin to your glans
of penis at frenulum
, which cause painfull erection.
You require to visit a surgeon and if needed go for circumcision
I hope i have answered your query.
Best wishes for your health.