Question: I have always stored food under my bed and have just found out that one shouldn't place food there. Do I need to dispose of it?
Answer: The Gemara (Pesachim 112a) writes that one shouldn't store food under a bed, as a ruach ra’ah, evil spirit, will pass over it. While the Shulchan Aruch (YD 116:5) paskens this way, Rambam (Hilchos Rotzeach 12:5) gives a different reason as he holds that this evil spirit no longer exists (See Lechem Mishne, Hilchos Shevisas Asor 3:2).
R’ Yitzchak Yaakov Weiss (Minchas Yitzchak 4:117) writes that one may place food at the bottom of a buggy, even if the baby is sleeping.
Medications are not considered food and may be stored under one’s bed (Halichos Shlomo, Tefilla 13:17; Tzitz Eliezer 17:35).
R’ Ovadia Yosef (Yabia Omer 1: YD 9) writes that as the Vilna Gaon and many others were stringent, if one did inadvertently place food under a bed, one should dispose of it. If the food was expensive, however, one may rely on the more lenient authorities. There are other factors, however, which would make the food permissible, including if the food was raw, if it was a child’s bed, or a carpeted / tiled floor (Yabia Omer 1: YD 10; Tzitz Eliezer 10:35).Most people follow other Poskim (Aruch Hashulchan YD 116:11; Pischei Teshuvah YD 116:4; Rivevos Ephraim 1:8:1; 5:8) who take a more lenient approach, and allow such food to be consumed.
In conclusion, one must be careful not to store food under one's bed. If one inadvertently does so, one need not dispose of it.