Opium is the milky substance that is extracted from the seed pod of the opium poppy once all of the petals have fallen off. It is composed of roughly 12% morphine (a narcotic prohibited in-competition), codeine, and a number of other non-narcotic alkaloids. The seed pod that contains opium also happens to contain the seeds (poppy seeds). While the seeds don’t contain morphine, during harvesting the seeds can become coated by, or absorb some of the opium extract. Most of the opium is removed from the seeds during processing (usually more than 90%), but in some cases, the poppy seeds sold for use in foods still have a significant amount of opium (and thus morphine) on them.
How well the poppy seeds are cleaned and processed will determine how much morphine residue is on the seeds, and this varies depending on which country the seeds are from as well as how and when they were harvested. However, it is known that morphine and codeine can sometimes be detected in the urine up to 48 hours after ingestion of poppy seed from some pastries such as bagels, muffins, and cakes (Reference 1 is a very interesting FREE article on this topic).
According to the WADA Prohibited List, morphine is a threshold substance and WADA-accredited laboratories determine a test is positive for morphine when the level of morphine in the urine is greater than 1.3 micrograms/mL. In most cases, consumption of poppy seeds in foods will not cause a positive doping test, but it may be possible to exceed the morphine threshold by eating foods with poppy seeds.
USADA cannot predict the amount of poppy seeds you can eat and still be below the testing threshold set by WADA, nor can USADA predict how long morphine or morphine metabolites from poppy seeds will stay in your system. The most conservative approach would be to avoid poppy seeds in the lead up to, and during, competitions .
Thevis M, Opfermann G, Schänzer W. Urinary Concentrations of Morphine and Codeine After Consumption of Poppy Seeds. J Anal Toxicol (January-February 2003) 27(1): 53-56 . URL: http://www.ncbi.nlm.nih.gov/pubmed?term=morphine%20and%20codeine%20on%20poppy%20seeds%20thevis
Lachenmeier DW, Sproll C, Musshoff F. Poppy seed foods and opiate drug testing—where are we today? Ther Drug Monitor. 2010 Feb; 32(1): 11-18.
Moeller MR, Hammer K, Engel O. Poppy seed consumption and toxicological analysis of blood and urine samples. Forensic Sci Int. 2004 Jun 16; 143(2-3): 183-186.
 There is an exception to this rule. If a diuretic or masking agent is also detected in the sample, an adverse analytical finding (i.e. a positive test) is reported for both the diuretic and morphine irrespective of the level, unless the athlete has a Therapeutic Use Exemption for both substances.
 As of December 2015, USADA has never sanctioned an athlete due to the consumption of poppy seeds.