you are planning to only travel through the US in transit, this means you still need to apply for an ESTA travel authorization.
When you complete the ESTA application, the words "In Transit" and the final destination should be inserted into the address field under the heading "Address While In the United States", this will make it clear to the border secury officers that you’re only visiting the US in transit. If you ever decide to visit the US in the future for an actual vacation, not just transit, you need to apply for a new ESTA travel authorization with a different address.
You should apply for an ESTA authorization as soon as you can, just to be sure that your application will go through in time. It is recommended to not apply later than three days before you depart, but it is not unlikely that some people’s application doesn’t go through because of user error and they will need to reapply at the airport to be able to check in. Of course, you would want to avoid that at any cost, which is why it is recommended to apply as soon as you book your trip. ESTA authorizations cost a few bucks, but are not nearly as expensive as actual visa’s. Payment goes via credit card.