Ahh, quick! Make sure you keep the food in an airtight tub (or put it in a bag and whack it in the freezer) and squish any of the moths that got out. They're called mealmoths and you often find them in pet food as they're rife amongst petshop suppliers (and then the petshops themselves get infested) and they can be a nightmare to get rid of! They have little larvae which climb into any little gaps they can find or up your walls and then hatch into the moths.
If you take it back for a refund ask to check the new bag before you go home - they shouldn't mind (afterall, if it is infested you'd be bringing it back again anyway and if not you'd open it at home!) but if they do then open it as soon as you get out of the shop. Often if they're in one bag they'll be in the other bags that were on the shelf nearby or in the same delivery