It's earlier than you think.
This week, the American Academy of Pediatrics published an updated set of guidelines for preventing allergies in children, replacing the AAP's 2008 report on the same topic. It delves into how and when to introduce certain high-risk allergenic foods (peanuts, cow's milk, eggs, shellfish, wheat, soy, and tree nuts are the big ones) to babies, and it turns out the optimal window of time is between four and six months of age.
In the case of all the aforementioned foods (besides peanuts, which we'll get to in a minute), there's not enough evidence to prove that delaying their introduction past the six-month mark does anything to prevent allergies. This is significant because for years, doctors recommended holding off on giving babies high-risk foods for as long as possible. "There is no reason to delay giving your baby foods that are thought of as allergens like peanut products, eggs or fish," Dr. Scott Sicherer, a co-author of the report, said in a statement. "These foods can be added to the diet early, just like foods that are not common allergens, like rice, fruits or vegetables."
As for peanuts, the new report states that introducing them as early as four months may stop the development of peanut allergies in infants at high risk (defined at those who have close relatives with a history of allergies). Back in 2000, the AAP warned against giving children peanuts until they were at least three years old.
The report also covered the effect of breastfeeding on food allergies, and while there wasn't enough evidence to connect the two, researchers did find that babies who are exclusively breastfed for the first three to four months of life may be less likely to develop eczema, while those who are breastfed beyond four months may be less likely to develop childhood wheezing and asthma.