In fact, in this case, the asteroid was detected independently by the SONEAR survey in Brazil and the ASAS-SN telescope network run by Ohio State University. Neither of these would fall under the "jurisdiction" of NASA or any governmental organization that would effectively be able to prevent them from talking about it. ASAS-SN tweeted the discovery, and I'm quite sure they didn't have to ask anyone permission to do so.
Secondly, the first few observations of a newly-discovered near-Earth object are generally not enough information to calculate the object's orbit accurately enough to know if it will hit Earth or not. So what do scientists do when they discover one? They immediately report it to the IAU and get the word out to as many other astronomers as possible, in order to obtain more observations & accurately determine the orbit.
As a result, it's hard to imagine how such a discovery could be kept secret.