Bee there, done that. Usually bugs comes from buying some unprocessed
grain; usually something like bird seed, or food or spices from a
foreign foods market. From my experience with food moths in my
cupboards, first throw away anything that looks suspicious. Any old
rice, grains, cereal. Inspect for webs or larvae. Even if its in
plastic they can eat through it. Glass jars with rubber seals are the
only insect-proof way to store food.
If they don't go away, then things get drastic. They are in the walls
and you need to starve them out, or have a terminix guy spray poison.
I didn't like the idea of poison near my cupboards so I took a safer,
but more difficult route. I threw out everything in the cupboard and
made do for about 30 days, storing the new stuff I bought in another
room. After a month the insects in the walls were dead and I restored
the food to the cupboard, problem gone.