All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
You are not sinful, Allah willing, if the insects are burnt when burning the herbs and the like, because your intention is not to burn the insects in principle.
It is well established in jurisprudence rulings that subordinate matters may be pardonable unlike principal ones, and that it is possible to judge some matters as valid when they are subordinate, while they cannot be judged as such when they are independent. As-Suyooti said in Al-Ashbaah Wan-Nathaa’ir: “Pardon is acceptable in that which is done as an implication, but not when it is intended in and of itself.” [End of Quote]
Nonetheless, a group of jurists believe that burning insects is not forbidden in the first place, even if they are not harmful, so it is with greater reason that it is not prohibited in the case that you mentioned in the question.
Ghidhaa’ Al-Albaab authored by As-Safareeni reads: “The adopted opinion according to the Hanbali School is that burning insects like ants is disliked and not forbidden. Since you know that it is disliked, so you should know that it is not disliked [to burn them] when there is a need."
Allah knows best.