Q. To avoid having the wasps in the suka, can you put outside food or honey that attracts them on Shabos and Yom Tov or is it feeding animals that don’t belong to you?

A. Shulchan Aruch (O.H. 324: 11) rules that one should not feed water or food to bees on Shabbos. Mishnah Berurah (ibid. 29) explains that this applies even if the bees belong to the one feeding them. The reason being that since it is not necessary to feed them, as they usually take care of themselves, feeding them is a prohibited unnecessary effort. (Tos’ Shabbos 19a)

However, Horav Shlomo Miller’s Shlit’a opinion is that since your intention in this particular case is not really to provide food for them but rather the great need of not having bees and wasps in your Sukah, it is therefore permitted.

(There are other grounds mentioned for the prohibition of feeding ownerless animals, such as maybe you will come to trap them or handle them while being Muktzeh (see Piskey Teshuvos 497), also you may come to grind their food (see Rambam H’ Shabbos 21: 35 and Nefesh Kol Chai 12: 1), reasons that do not apply in our case)

Rabbi A. Bartfeld as revised by Horav Shlomo Miller Shlit”a