The AP reports that it wasn't until late August (just a few weeks before his arrest) and that it wasn't from any domestic law-enforcement agency but from the CIA:
The CIA learned about Zazi through one of its sources and alerted domestic agencies, including the FBI, intelligence officials said.
U.S. intelligence organizations first became aware of Zazi in late August, a senior administration official said. The intelligence and administration officials declined to offer more details on the operative and spoke on condition of anonymity because the investigation is ongoing.
If this is all true, then it's a case of our counterterrorism efforts working as they should--with the CIA, FBI, and local police cooperating successfully (at least until the NYPD apparently tipped off Zazi to the investigation). But it's also a bit frightening, too, that Zazi was allegedly going about his terror preparations here in such a way that he didn't arouse anyone's suspicions.