They enter in products that were contaminated before you brought them home. While beetles such as the flour beetle, meal worm, and grain weevils make the product unappealing they are not harmful. Sift them out of flour or mixes that are only slightly contaminated. If the product is riddled with the beetles discard it.
Moths leave a grayish white silky mat on the food product.
To get rid of the infestation, remove all foods from the infected area and wash the area thoroughly. You may apply an approved pesticide for use in food areas in the cracks and crevices that you cannot reach to clean. Store foods in tightly closed containers to keep the food source away from any remaining beetles. Use glass, plastic and metal containers with tight fitting lids. Buy spices in bottles instead of metal containers with flip top closures.