All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
According to the preponderant scholarly opinion, it is prohibited to kill locusts in the Sacred Precincts of Mecca, regardless of whether the person is in a state of ihram or not. Whoever does so is subject to a penalty, which is to pay the value of what he killed thereof. Another opinion suggests that he should give one date in charity for each locust that he killed. In Al-Majmoo‘, An-Nawawi said:
According to our view, a penalty is due on a person in a state of ihram for destroying locusts. This view was held by ‘Umar, ‘Uthman, Ibn ‘Abbas, and ‘Ata’. Al-‘Abdari said, "This is the opinion of all scholars, except for Abu Sa‘eed Al-Istakhri, who said, 'It entails no penalty.'"
The following is stated in Kashshaf Al-Qina‘ of Al-Buhooti:
Locusts belong to the game of the land, so killing them entails paying an equivalent of their value in the place where they live. This is because locusts are land flying beings like sparrows, and killing them is like killing game that has no equivalent of eatable animals. According to the author, a date should be given in charity for each locust. In Al-Mughni, Ibn Qudaamah said, "Hunting in the Sacred Precincts is forbidden for those in a state of ihram or otherwise. The origin of this prohibition is the text and consensus. As for the text, Ibn ‘Abbas related that the Prophet, sallallaahu ‘alayhi wa sallam, said on the day of the conquest of Mecca, 'Allaah has made this town a sanctuary from the day that He created the heavens and the earth. So, it is a sanctuary by the decree of Allaah till the Day of Resurrection. Fighting in it was not legal for anyone before me, and it was made legal for me only for an hour by daytime. Thus, it is a sanctuary by the decree of Allaah till the Day of Resurrection. Its plants should not be cut or struck, its thorny bushes should not be cut or uprooted, and its game should not be chased.' [Al-Bukhari and Muslim]. Muslims unanimously regarded hunting in the Sacred Precincts of Mecca as forbidden for those in a state of ihram and otherwise." He (Ibn Qudaamah) also said, "What should be forbidden and guaranteed in the state of ihram should also be forbidden and guaranteed in the Sacred Mosque."
Accordingly, you should give the value of the locusts that you destroyed in charity. If you do not know their number, then adhere to cautiousness in estimating their number, for a duty is not properly fulfilled except through certainty.
Allaah Knows best.