What makes some saliva sour?

I have on occasion experienced a rather unpleasant burst of weird-tasting spit. It seems to happen when a distasteful substance is in my mouth. What chemical causes that weird taste, and what does it accomplish?

“Gigantor’s a space age robot. He’s at… your command! Gigantor’s a space age robot. His power is… in your hands!”

Do you think you may have brought up some gastric juices into your mouth somehow? It happens sometimes when I belch.

Naw, when that happens I know it. Hurts like hell. The stuff I am referring to comes straight from under the tongue, usually in a sizeable quantity. Have you ever eaten something acidic or spicy right after you’ve woken up in the morning? Sometimes that brings it on.