The advice was issued by the Committee on the Toxicity of Food in a report on the growth of peanut allergy in Britain. It is expected to affect up to a third of pregnant and breast-feeding women.
The report said women who suffer from common conditions such as asthma, hay fever and eczema, or whose partners or other children suffer from them, could pass on the peanut allergy to their unborn babies.
Sir Kenneth Calman, the Government's Chief Medical Officer, said the advice was precautionary but based on evidence suggesting foetuses and infants exposed to peanuts were more at risk of developing the allergy.
Peanut allergy is rare but deadly. It is estimated to strike one person in 200 and cause five to seven deaths a year. Children are particularly at risk.
Even very small amounts can trigger a severe reaction in sensitive individuals, resulting in anaphylactic shock.
Sir Kenneth said the risk of a mother sensitising her child during pregnancy or breast-feeding had to be considered due to the known genetic link.
"The committee is therefore advising that pregnant or breast-feeding women who suffer from diagnosed allergic conditions, or where the father or any brother or sister of the child has a clinical history of such conditions, may wish to avoid eating peanuts and foods containing peanut products.
"There is no reason for pregnant or nursing mothers who do not fall into this category to avoid eating peanuts. Refined peanut oils or vegetable oils are unlikely to cause a problem."
Families who suffer allergies are being advised to prevent their children eating foods containing peanuts until they are three years old. And no child under five, irrespective of their family history, should be given whole peanuts due to the risk of choking, Sir Kenneth said.
Parents of affected children were urged to read labels carefully in case products contained traces of peanuts, and to avoid accidental cross-contamination when preparing food at home. The Ministry of Agriculture launched a campaign last November urging more care in labelling food containing peanuts.
Sir Kenneth added that eating peanuts remained safe for the "overwhelming majority" of the population.
"The advice will go a long way towards helping prevent the handful of dramatic and tragic deaths we do see each year and will, we hope, start to limit the growth of peanut allergy in this country.
"It is definitely an instance where an ounce of prevention is worth a pound of cure."
David Reading, of the Anaphylaxis Campaign, welcomed the move, saying: "This is a good safe message. What we hope is that if this is followed, soon we will start to see the number of people suffering peanut allergies go down."
He added nobody need die if they avoided the nuts and made sure they carried the right medication, usually adrenaline, to treat a severe reaction.
Leaflets are being sent to all GPs with details of the advice.