To keep bugs out of your flour, freeze the new flour for 3 to 4 days and then transfer the flour to an airtight container and then add natural bug repellents to the flour like bay leaves.
Eggs for the bugs can be present when you buy the flour and so you need to eliminate these eggs that could be present by freezing the flour.
Immediately place any newly purchased flour in your freezer for 3 days to 4 days or even 7 days.
And the freezing temperatures will permanently neutralize and kill any unhatched bug eggs or larvae that can be in the flour.
And never leave your flour in the original paper bag that the flour comes in, as bugs can easily chew through the paper bag.
Instead transfer the flour from the paper bag, into a glass jar like glass mason jars or even heavy duty plastic containers that have silicone seals.
Dropping 1 or 2 whole bay leaves or even a few cinnamon sticks directly into the flour container can also help keep bugs out of your flour as the scent of the whole bay leaves or cinnamon sticks act as good natural deterrents for bugs like weevils and other pantry pests that can be in your flour.
And if you buy your flour in bulk, you can also use a vacuum sealing system or even an automatic jar sealer to extract all of the air.
And then vacuum sealed flour can remain free of bugs and even fresh for up to 2 years time.
Then when you're ready to bake or use the flour, take your flour out and allow your flour to come completely to room temperature while the container also remains sealed.
This will prevent any moisture and condensation from ruining the flours texture.
Having some bugs in your flour can be normal and does not mean you need to throw the flour out.
Although if the flour is heavily infested with bugs and you can't sift all the bugs out of the flour then it should be thrown out.
If the flour is heavily infested, then the flour is likely contaminated, but if it's just a few bugs then the flour is often safe to use.