Pantry moths arrive in food. Rice, flour, nuts, grains, etc, are common. You can get pantry moth traps to attract and kill the living ones but there'll still be eggs in your food stuffs. You need to clear that stuff out "with a fine tooth comb".
Depending on what the food is, you can freeze a container (of rice for example) then wash the rice and sift the dead moths/eggs out. Failing that, dump anything they've infested and start over. - ProjectPete
Wash out every cupboard with a bay leaf tea, concentrating on any joints or hiding places and maybe using a brush. Dispose of any noticeably infected foods and you will recognise this by webbing in the food.
Dispose of the infected and keep the good, checking all the lips under the lids, under the base, etc. Dry and insert dry bay leaves in products. It won't ruin the flavour but it deters moth. I still top up with bay leaves. I put bay leaves in my food canisters. I surface spray underneath the cornice and I surface spray inside my drawers.
I have used dozens of the pantry moth traps you can buy for around about $12. They were filled in 5 minutes. It was persistence and physical labour to destroy any cocoons that were visible up high that conquered it. - WallsendWoman
We had this problem years ago and simply freeze everything for a few days that could have the eggs in them, since then we have had no infestations. - wooshka
Bay leaves are the secret to controlling the little beasties. After a bad infestation I think it is wise to clean everything down, chuck any offending food and get ready to start again. I have a bay tree (also known as laurel tree) and I just scatter the green bay leaves straight from the tree onto the pantry shelves. As they dry I just add a few more green ones, so generally there is a mix of green and dry leaves on the pantry shelves. I also scatter them on top of my rice and then shut the lid tightly.
Cockroaches don’t like bay leaves either. A bay leaf tree is easy to grow in a pot or garden. I have one in the garden and one in a pot close to the kitchen. My tree is about 30 feet high and is over 20 years old. - LizzieBee
We have tried using moth balls to remove them, but they don't seem to do anything and just smell awful. We threw out nearly everything (being on the cautious side to avoid having to do this again). Coated the entire pantry in bug spray and left overnight. We then used disinfectant and scrubbed every single inch. Our pantries have brick walls so we scrubbed them down twice to remove any left over eggs that might be hiding in the mortar. I also bought pantry moth traps to try and stop them from coming back. - kaylah_rose
We've had them before and they prompted us to move to airtight containers and jars for everything. - Jason