What to do if I have anal discharge what could it be?

Get an examination. It could be lots of things. Sometimes a discharge is related to hemorrhoids, or anal warts, or fistula. Sometimes it's related to decreased anal sphincter tone. It could be related to diabetes. Go see a colorectal surgeon for a specialty evaluation.