Hi there ~
I understand your concern. I am glad you bring this up in a public forum. What you have is secretions from glands surrounding the glans
of your penis. I hope you have good sexual hygiene and clean your genital area by pulling the foreskin back everyday. This should prevent any balanitis
which is infection and inflammation of the skin surrounding the foreskin and prevent the bad odor as well. You may also have phimosis
which might be the reason you are having pain when the head of your penis is not covered by prepuce. I hope you consult a surgeon for possible surgery. Also it may be that you might need a dermatologist
for concerns that might need other greater investigations and testing. I hope this helps.
Take care and have a lovely day !