Here's a very general outline.
First, on the plane, you will be asked to fill in a short form for customs. This contains information about who you're travelling with, where you're travelling from, and what you're bringing into the country. It's therefore a good idea to have a pen in your carry on luggage.
After getting off the plane, you come to the immigration check. This is where your visa or ESTA will be checked, and immigration officers will determine if you are allowed in the USA. There may be machines where you are supposed to enter some information before speaking to immigration, depending on the airport.
After clearing immigration, you will pick up your bags and take them through customs. Here you will typically be asked by a customs agent to verify your answers on the customs declaration form you filled in on the plane. The agent will determine if you need to pay any duties or if anything in your luggage needs to be quarantined or destroyed. They may decide to search your bags.
These things will always happen. What happens next depends on the airport and your specific itinerary.
The easiest scenario is that you immediately hand over your bag to a staff member from your airline and proceed to your gate. There may or may not be a security checkpoint before you can go to your connecting flight.
Otherwise, you will need to recheck your luggage and go through a security checkpoint before proceeding to your gate, same as you did to get on the flight to the US.