Go through these in order and stop at the first one that applies. If you are reading this for someone else, answer for them.
Go to an emergency department for an erection lasting about four hours, particularly if it is painful or unrelated to sexual stimulation.
This is called priapism.
Delayed treatment can damage penile tissue.
Call emergency services for chest pain, severe breathlessness, fainting, or other possible heart symptoms during sexual activity.
Stop sexual activity while waiting for help.
Seek urgent assessment after a genital injury, especially if there was a cracking or popping sensation, immediate loss of the erection, marked swelling, bruising, or severe pain.
Arrange a routine medical appointment if a sexual problem keeps happening, causes distress, or is a noticeable change from your usual function.
You should also seek assessment for reduced desire with tiredness or other possible hormone symptoms, pain during sex, a new penile curve, or a problem that began after starting a medicine.
The article also says
Mention erection problems even if you do not want treatment for sex itself.
They may justify checks for diabetes, blood pressure, cholesterol, or other health concerns.
Every sign above is quoted from the sofidex article on Male sexual problems. If you are not sure, err upward — it is always reasonable to be checked.