The link is suggested by a study of 19,000 women in the US who were asked about their diet in the year leading up to pregnancy.
A healthy diet was one with plenty of fresh fish, fruit, nuts and vegetables.
Pregnant women and women trying to conceive are already advised to take certain supplements.
Experts recommend folic acid to reduce the risk of other birth defects like spina bifida, and vitamin D for healthy bones and teeth.
In England, the government's Healthy Start scheme provides vouchers for pregnant women that can be used to buy milk and vegetables.
In the study, published in Archives of Diseases in Childhood Fetal & Neonatal Edition, half of the women had babies with heart problems while the other half did not.
When the researchers compared the diets of these two groups they found a healthier maternal diet was associated with a lower chance of congenital heart defects.
Pregnant women in the top 25% (quartile) of diet quality, had a lower risk of having a baby with certain heart defects - atrial septal defects and Tetralogy of Fallot - than those in the bottom 25%, even after accounting for other factors such as whether the mother took folic acid or was a smoker.
Congenital heart disease is one of the most common types of birth defect, affecting up to nine in every 1,000 babies born in the UK.
Mild defects, such as holes in the heart, often don't need to be treated, as they may improve on their own and may not cause any further problems. But others can be more serious and some, lethal.
In most cases, something has gone wrong in the early development of the foetus. Some heart conditions are due to faulty genes or chromosomes. But often it is unclear why the baby's heart has not developed normally, says the British Heart Foundation (BHF).
Victoria Taylor, senior dietitian at the BHF, said: "This is an interesting study which highlights the importance of diet right from the start of life.
"A healthy diet before, during and after pregnancy can have benefits for both mother and child and, as seen here, the whole diet should be taken into consideration, rather than solely focusing on individual nutrients.
"Eating well isn't a guaranteed way to avoid congenital heart defects, but this will be another factor that will motivate women planning a pregnancy to make healthy choices."

There was an eight-fold increase in the time it took West Yorkshire Police to answer calls in 2015 compared to 2013, figures obtained by the BBC show.
In South Yorkshire the time tripled and more than doubled in North Yorkshire.
Police crime commissioner for West Yorkshire said extra staff had been recruited to bring response times down.
Figures, released under a Freedom of Information request, showed between April 2013 and April 2014 it took West Yorkshire Police on average 14 seconds to answer 101 calls.
That increased to one minute 46 seconds from April 2014 to April 2015, despite a drop in the number of people using the service.
Caller waiting times continued to increase in the eight months between April and November 2015.
Figures also showed the number of people hanging up before calls were answered had more than doubled from 5% in 2013 to 11% in 2015.
John Summerscale, a former special constable from Bradford, said he had experienced many delays.
"I was told by the police it should take four rings before someone answers but I've been waiting up to 20 minutes and still no answer."
Mark Burns Williamson, West Yorkshire police crime commissioner, blamed the delays on budget cuts but said extra staff had since been recruited to address the problem.
He said: "Such delays are unacceptable and I was being contacted by members of the public who weren't happy.
"We've got waiting times down now to between 18 and 60 seconds and there is a higher level of customer satisfaction with the service."
Elsewhere, it took South Yorkshire Police an average of 30 seconds to answer calls in 2013/14, rising to just under a minute and a half in 2014/2015.
In North Yorkshire, the length of time went up from 23 seconds in 2013/14 to just under a minute in 2014/2015.
Crime commissioners for both forces said improvements were being made including new technology and better online reporting of crimes.
Women who eat healthily before and during pregnancy may cut the risk of their baby developing a heart problem, researchers believe.
[NEXT_CONCEPT]
Callers to the 101 non-emergency service at three Yorkshire police forces are having to wait longer to get through compared to two years ago.