According to a study of 1.5 billion airfares in 2014 by CheapAir.com, the best time to book a domestic flight on average is 47 days before the flight. For international flights, purchasing your ticket at least three months in advance will generally get you a lower fare.
Fares for domestic flights generally go down steadily until about 47 days before the flight, when they tend to skyrocket.
There is much more variation when it comes to international flights, because of the wide range of areas and distances involved. To travel to Central or South America, you will generally get the best fare about 96 days before the flight. If you are flying to the Middle East, CheapAir.com says you will tend to get the lowest fares if you buy 213 days in advance. You should book 276 days in advance for Europe, and 318 days in advance if you are going to Asia.