You can by seed moth traps, I think they are under 5 $.
They are sticky tape tents that have a little rubber thing
inside that gives off pheromones. These pheromones attract
and trap the males (or maybe the famales, cant remember), so
that the other sex can not breed and they die without having
Be sure to also check the folds in the packaging of the
products you buy. The folds in the bottom corners of stand
up bags are perfect hidding spots for the larvae.
You can also store your excess food in the freezer in weekly
portions in well sealed packaging, and pull out of the
freezer as needed. Do not keep it all together and pull
in/out of freezer as this can creat condensation (going from
room temp to cold) that can cause your food to spoil.
Someone else will probably be able to help you more. I
myself have been lucky enough to never have this problem, I
don't have much "how to" info on it.