They're always around. You can prevent reinfestation with tight containers. Boris recommends that breads and cereal products, plus any bird food kept in garages, be stored in containers with tightly fitting lids. Lids alone are not enough if they fit poorly or too loosely. The technical literature is loaded with such studies.
Insects communicate and navigate by producing and detecting chemicals.
Folk remedies that recommend protecting stored foods by lacing them with aromatic herbs have some real potential. If aromatic plants produce chemicals that can either disrupt an insect's detection senses or mask a target food's own unique aromas, they may deter insect infestation. The mustard, mint, celery, and onion families all contain species that produce strongly aromatic chemicals. Thus, garlic, chive, parsley, cumin, dill, lavender, catnip, rosemary, kale, cabbage, and radish, among others, have been variously employed as traditional pest deterrents. I have not found any studies that unequivocally prove these traditional herbs do not attract certain pests, much less repel them.