The Torah in Parashat Shemini (Vayikra 11:42) forbids eating “Kol Ha’sheretz Ha’shoretz Al Ha’aretz” (“all the crawling creatures which crawl on the ground”), which the Sefer Ha’hinuch explains as referring to insects which grow in fruits and vegetables and have left onto the ground. Once these insects leave the fruit or vegetable in which they have grown, they are forbidden for consumption. As long as they remain inside the fruit or vegetable, there is no prohibition against eating them, but once they leave, they are forbidden, even if they then return to the fruit.
This prohibition applies only to insects that grow in produce while the produce was still attached to the ground. Insects that grow in produce after harvesting are not included in this prohibition. However, as the Sefer Ha’hinuch writes, it is all but impossible to determine whether an insect grew in a fruit or vegetable before or after it was harvested, and thus we must refrain from all insects that grow in produce.
The Rambam, in Sefer Ha’misvot, rules that if an insect emerged from inside a fruit, but remained on the fruit’s surface instead of leaving and going onto the ground, it is nevertheless included in the prohibition, and one would be liable to Malkut for eating such a creature. The Sefer Ha’hinuch notes that this ruling is mistaken, because the Gemara writes explicitly that the insect’s status at this point is uncertain, and thus, while it is forbidden to eat the insect, one would not be liable to Malkut if he does, given the uncertainty of its status. In fact, the Rambam himself, in his Yad Ha’hazaka, codifies the Gemara’s ruling that the insect’s status if it remained on the fruit’s surface is uncertain.
Insects found inside fish are assumed to have originated outside the fish, and are thus forbidden. This applies also to insects found inside the stomach of an animal.
Insects found in water are permissible if they grew in the water, but not if they originated outside the water and then went into the water. (A number of years ago, there was a debate concerning small insects found in the New York City water system, as it was uncertain whether they originated outside the water or grew in the water.)
This prohibition, of course, applies in all times and in all places, and to both males and females. One who intentionally eats a complete insect is liable to Malkut. If, however, the insect is incomplete – even it is missing just a single leg – then one is not liable to Malkut unless he consumes a Ke’zayit of insects.
In order to avoid this Biblical command, it is imperative that one carefully inspects his produce to ensure that they do not contain insects. The Gemara in Masechet Makkot states that it is possible to violate five or six commands by consuming an insect.
It is famously told that the Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909) once saw a woman checking lettuce on Ereb Pesah casually, without making a thorough inspection. He turned to the woman and asked how many hairs were on her head.
“How many hairs?!” she asked. “There are so many – I cannot possibly know how many!”
“You will be responsible for more violations than hairs on your head for failing to properly check the lettuce,” the Rabbi said. He explained that each guest she will be serving at the Seder could end up consuming large numbers of insects, and for each one, he will be liable to numerous sets of Malkut, because of her failure to inspect the produce…
To give us some perspective, if a person eats a hamburger in a non-kosher restaurant, he transgresses only a single prohibition – the consumption of Nebela (meat from an animal which was not properly slaughtered) or Terefa (meat from an animal with a terminal physical ailment). But if one eats a salad in a non-kosher restaurant, he violates hundreds of prohibitions, as he consumes an untold number of insects. It is thus vitally important to exercise caution in this regard and ensure to avoid eating produce which has not been properly inspected.

