Jonik's recommendation of 2-3 hours is a good average time, but several factors might influence the amount of time you should give yourself:
1) How large the airport you are connecting through is. Smaller airports typically mean less traffic so lines will be shorter. However, some larger airports are more efficient than small ones (so lines move quicker). You should also take into consideration the time it will take you to get between gates. If your flights arrive and depart from the same terminal, it will likely take you only a few minutes to walk from one to the other. If you have to go to a new terminal, though, keep in mind that it can sometimes take a half an hour to get from one terminal to the next. (I'm thinking of large airports like NYC's JFK where you might have to walk for 15 minutes to get to the AirTrain, wait for the train, time on the train, etc.) If possible, try to find out what your arrival and departure gates/terminals are in advance. Size of the airport should be considered directly with point #2 as well.
2) Day and time you'll be passing through the airport. Mondays and Fridays are typically busier than, say, Tuesdays and Thursdays because business travel often starts and ends at the beginning and end of the work week. Time of day is also important to consider; you'll need less time if you're traveling at an off-peak hour. For example, I recently arrived in Newark (EWR) at about 4:45 AM on a Monday morning; my flight from India was the only one that had arrived around that time, so passport and customs were pretty empty - only people from my flight were in line. If you're passing through at noon on a Saturday, though, chances are that lines will be longer because of more flight traffic.
3) Season of travel and the weather at all points on your trip. If you're connecting through a US city in the Northeast in January, you'll probably want to give yourself extra time because weather delays are probable because of the amount of snow the region gets. Same goes for Southern US in August - rain/thunderstorms can delay both incoming and outbound flights.
3) Whether your luggage is all carry-on, or if you're checking bags. To my knowledge, US Customs and Border Protection requires that all people entering the US from an international flight must claim their check-in luggage at baggage claim prior to going through customs, and then (if you are continuing to somewhere else in the US or to another international flight), you must re-check your luggage after customs. That will add more time to your transfer; first you have to wait for you luggage to be unloaded from the plane, and then you may have to wait in line to re-check it. Personally, I avoid checking luggage whenever possible - if my trip is less than a month, I almost never check a bag. Easier all around. :)
NOTE: There's also a new-ish program called the Global Entry program, which is supposed to save time for low-risk travelers entering the US. You can do passport control at a self-service kiosk, which usually means not waiting in line at all. I have no personal experience with it, so I can't vouch for it as a time-saver, but it's something to consider.
4) Your comfort level. Some people find travel very stressful, while others stay totally calm even when things fall apart. Part of your determining how much time you need is to think about how you react in stressful situations. If your flight is delayed and you see 100 people in line at customs, will you panic, or will you trust that lines will move quickly? I'm a mid-level anxiety traveler; I usually give myself an hour longer than whatever my sources recommend (whether that's an airport / airline website, or a friend who's had experience with the places I'm going). It gives me better peace of mind and makes traveling more pleasant for me; I don't mind having extra time to kill at airports. In this case, 2-3 hours is a totally reasonable recommendation, but I would probably give myself something more like 3-4 hours. It's largely personal preference, though.