If you find small (but visible) pieces of dirt on your food or drink is it permissible to eat it? Are there sources that discuss this?
By dirt I mean "an unknown foreign object that makes the food look bad".
Based on the verse (Lev. 11:43), אל תשקצו את נפשותיכם - "do not make yourselves detestable," there is indeed a halachah that one may not eat things that are disgusting to the average person. Shulchan Aruch (Yoreh De'ah 116:6) puts it as follows:
אסור לאכול מאכלים ומשקים שנפשו של אדם קצה בהם, כגון משקים ואוכלים שנתערבו בהם קיא או צואה או ליחה סרוחה וכיוצא בהם... שכל אלו בכלל אל תשקצו את נפשותיכם
It is forbidden to eat foods and drinks that are repellent to a [normal] person, such as drinks or foods into which vomit, excreta, pus or the like have been mixed... for all of these are included in the [prohibition], "Do not make yourselves detestable."
The Gemara in Shabbas 113b brings down a discussion about eating dirt. Rebbe asks can one eat dirt on shabbas because of refuah?
Rabbi Yismael b' Rebbi Yossi says it is forbidden even during the week since it makes one sick.
Rav Ami: Eating dirt from Bavel is like eating ones ancestors. Some say it is like eating shrutzim and rumasim.
The Chachamim forbade it because of it being unhealthy and because of shratzim u'rumasim.
A person one time ate clean dirt and it sprouted inside of him and reached his heart and he died.