In my experience, waiting 2-4 weeks before the flight is the best time to buy tickets. Last year, I planned an October trip from LAX->SFO->LAX. When I checked 4 months before the flight, the price was $220. When I checked 4 weeks before the flight, the price was $90.
But these are just for...