Every inventor, applicant, assignee, attorney/agent, and whoever else involved in prosecuting a patent application has the duty of candor to disclose prior art that is material to the examination of the application.
Here, "material" means anything that would make the application unpatentable; anything that is contrary to the examiner's position; or anything that would help a patent examiner prosecute the application at hand. Usually, previously registered patents, patent application publications, and other types of publications are cited in an information disclosure statement (IDS). How do you know which previously registered patents, patent application publications, and/or other publications should be cited? Sometimes you just know from conducting your own research when making your invention. But most of the times, you know from conducting a patent search.
The best time to file an IDS, in my opinion, is when you first file your application materials. That way, you get it out of the way from the beginning and you don't have to pay anything for submitting the IDS. But if you can't file it from the very beginning, you have three months to file it. After three months of filing the application or after the first office action (whichever is later), you have to pay $180 to file an IDS. Additionally, you have to submit a 37 C.F.R. §1.97(e) statement.
Under 37 C.F.R. §1.97(e), you have to state that:
(1) that each item of information contained in the IDS was first cited in a communication from a foreign patent office in a counterpart foreign application not more than three months prior to the filing of the IDS; or
(2) that no item of information contained in the IDS was cited in a communication from a foreign patent office in a counterpart foreign application, and, to the knowledge of the person signing the certification after making reasonable inquiry, no item of information contained in the IDS was known to any individual designated in §1.56(c) more than three months prior to the filing of the IDS.
After a final office action or after receiving a notice of allowance, you still have to pay the $180 fee, make the 37 C.F.R. §1.97(e) statement, AND file an RCE. The RCE can cost $600 if it's the first request (small entity) or $850 if it's the second or subsequent request (small entity). After the issue fee is paid, you have to petition to withdraw the application from issuance and file an RCE. You can see here that it becomes much more of a hassle to file an IDS as the prosecution process progresses. But it's important to file an IDS because your duty of candor continues throughout the application process. Otherwise, your patent can be challenged and invalidated.