If you know that you require an Electronic System for Travel Authorization (ESTA) to board a flight to the U.S., it's always best to apply for an ESTA as early as possible, and no later than 72 hours before your trip. This will ensure that you have all the documents you need to board your flight.
Not sure if you need an ESTA? Visit the U.S. Customs and Border Protection website to find out.