What kind of fungal infection or STD cause internal pain in the anus penis and scrotum. I also have a rash in and around anus.?

Fungal infection? What makes you think that it's a fungal infection and not std? You need to see a md to run proper tests on you to make right diagnosis and then give you right treatment.
Hmmm. If you have chlamydia or gonorrhea it's possible. You would have likely had anal sex as well to get anal involvement. A rash could be due to another infection.