Maybe you don't have an outdoor pet. Alas, ants can still find their way into your house or apartment. The best way to deal with this problem is not to let it happen in the first place.
Ants, like humans, enjoy a good meal and they're always searching for food. When they find it, they tell their friends about it, and lay down a chemical trail inviting them to the party. To discourage ants from hanging around inside your house, especially the part of your house where your pets hang out, keep all food in sealed containers or in the fridge. Clean up any crumbs left behind after meals and snacks. (A pile of crumbs is like a grocery store to an ant, each crumb perfect for carrying back to the nest.) Get into the habit of moving used food to the trash or to the disposal unit in your sink as soon as possible. Take out the trash on a daily basis. That way, the ants may still get fed, but with any luck they'll be doing it away from your home -- and your pet. And be sure not to let your pet root around in the garbage. That's practically begging for an insect infestation!