Know the Rulebook
Different states have different laws about townhouse associations and homeowners' associations. These guidelines will define whether you have a townhouse association or a homeowner's association (HOA) and the responsibilities and limitations for such an association. The bureaucracy can stay simple, or get really complicated -- depending mostly on your state's laws and the size of your complex.
Then, within the association, there is another set of laws and bylaws. If you own your unit, you should have received a copy while you were buying or you can get one from your management. (If you're a renter in a townhouse and a problem comes up, ask your landlord.)
How, exactly, does all this pertain to pest extermination? Well, your state laws and your association rules and bylaws do (or should) outline exactly how pests should be dealt with -- whether the infestation affects individual units or a wider portion of the complex.
If, for example, you notice ants in your unit, it might be easy enough to grab a can of spray next time you're at the grocery store and wipe 'em out. After all, it's a small problem, and generally, you're responsible for whatever happens inside the walls of your home. But what if the ants are in your garage, and upon closer inspection, you notice they're crawling through a crack in the wall that's adjacent to your neighbor's garage? Is it still your problem, or can you hold your neighbor responsible? True, ants are hardly worth the trouble, but what if it was something more dangerous or damaging, like a swarm of wasps or cockroaches? What if the infestation was outside your home, coming from what's known as the complex's "common elements" area? Should your HOA pay the cost of the extermination if it affects more than one unit or has the potential to spread?
We aren't lawyers and can't give you those answers -- every townhouse association is different. Like we mentioned above, generally, you're responsible for problems contained within your walls. If your creepy-crawly problems migrate next door, you might have an obligation to help your neighbor (especially if it involves damage that might be covered by a homeowner's insurance policy). But when it comes to living things that move around, and cause superficial or structural damage, and might require toxic chemicals that can hurt children and pets that your neighbors might refuse to allow, it gets complicated. That's why there are (or should be, anyway) established rules. Look 'em up before you decide what steps to take. Sometimes the association's budget might cover the cost; in other situations, the association might decide to take action and bill each owner for their share of the expense. And sometimes it might be your own problem, with the additional burden of ensuring the bugs don't make a getaway.
All of this is easier, of course, if you can form a united front.