After customs.

All inbound citizens, nationals, and visitors must pass through immigration and customs at their first point of entry, regardless of whether they have connections to other destinations inside the U.S. Nearly all major hubs have special arrangements for travelers with connecting flights, such as a conveyor belt just the other side of customs where you can place your baggage that has been already been tagged with your final destination. (Some hubs like JFK have now switched to a more inconvenient system, where you must show your ID and boarding pass at a "Connecting Flights" check-in counter.)

Since you have had access to your checked bags while going through customs, you will always need to re-clear security if proceeding on to a connecting flight. Some airports (such as Philadelphia) have a bag drop belt right outside customs, followed by a dedicated security checkpoint just for passengers connecting from international flights. At others (such as Boston where domestic carriers all depart from terminals other than the one used for international arrivals), you will have to exit the terminal you are in and proceed to the terminal of your departing flight, drop your bags at your airline's counter and then proceed through the main security checkpoint.

Note that the bag drop procedures above work only if you have requested the staff at your port of departure to check your baggage through to your final destination (as opposed to your first U.S. port of entry). If this is not possible or there are no check-through agreements between the airline that took you to your port of entry and the next airline, you will have to proceed to the terminal from which your next flight departs and check-in as usual.

 

Unlike most countries, the U.S. has no formal passport control checkpoint for those exiting the country, especially for those traveling by air or sea. As such, if you are leaving the U.S. for the last time on a particular trip (i.e. not returning from Canada or Mexico), it is ultimately your responsibility to turnover the departure record of your I-94 or I-94(W) to the airline or ship staff at check-in, or the Canadian or Mexican border officer if leaving by land. If you leave the country with it, still in your possession, contact U.S. officials about how to return it and update your departure records to avoid entry hassles in the future. If you leave by a commercial carrier, your departure will also be verified with the airline or shipping company. Hence it (at least theoretically) means no further action is needed from you; nonetheless bring whatever documents to prove you were outside the U.S. before time was up the next time you visit. U.S. Customs and Border Protection has information about what to do if your slip is not collected.

If you intend to leave for Canada or Mexico by land for a side trip and return to the U.S. within 30 days or the allowed time of your stay (whichever is shorter), you may re-enter the U.S. provided that you do not yet return the I-94 or I-94 card before you proceed to Canada or Mexico. This can also be done even if you originally entered the U.S. on a single-entry visa. However, you will only be admitted for the remainder of your original allowed time; the deadline to ultimately leave the U.S. won't be extended by just leaving the U.S. for somewhere else in North America. If you return the I-94 while on the side trip, you will have to apply all over again to enter the U.S. (which means a new visa for single-entry visa holders) and be subject to the usual questioning that alien go through to lack of any intentions of immigrating, working, or doing something else not authorized by the visa.

That said, avoid re-entering the U.S. a few days, weeks or months after one visit. Even if you don't technically overstay, planning several U.S. visits spaced shortly after each other may be interpreted by immigration officers as having "immigrant intent" and hence your visa could be subject to cancellation the next time you apply for entry.

There are additional pilot security measures dubbed U.S.-VISIT that will eventually require non-resident aliens to be fingerprinted and photographed upon their exit. This is applicable at a majority of land, sea, and air entry ports.