Getting rid of food-infesting moths or beetles takes continuous, persistent effort at removing and cleaning up the infestation, especially if it has been present for a while. Some pests are capable of living for many weeks without food, so the threat of reinfestation exists until they die off or are killed. It is best, at least for several months after eliminating the infested products, to store any susceptible food in airtight containers or in the freezer. Storing food items (flour, grains, spices, bread crumbs etc) in the freezer prevents infestations from developing.
Usually, by the time the insects are noticed, they have already spread to other food packages. Inspect all packages, especially those that have been opened. Throw away anything that gives the slightest indication of infestation. Other than the insects themselves, signs of infestation include webbing in tight places of a package or tiny holes in the container. Insects are less likely to invade packages that have their original seal and usually infest those that have been opened or that have been on the shelf for a long time. Before replacing noninfested packages, wash shelves with soap and water, scrubbing corners and crevices or vacuuming them with a crevice attachment to remove eggs and pupae. This can be a frustrating process because items can be overlooked on the first attempt, so being as thorough as possible is important. Adult moths can be trapped with moth traps but they aren’t really as important as dealing with the source.