"If you can prevent it before it starts in childhood and adolescence you are shutting the gate before the horse bolts.
"Having good nutrition-rich foods is really important for adolescents because it's a time when they are growing rapidly and it's essential they have adequate nutrition."
One in five Australian adolescents have some form of mental health problem.
Genes and environmental factors such as stressful events in early childhood are already known to play a role.
Where diet fits in is through its influence on genes, the immune system and the main brain proteins linked to mental health problems.
In her study Dr Jacka analysed data from more than 3000 Victorian adolescents aged 11 to 18.
The participants filled in questionnaires about their diets and psychological symptoms in 2005 and again in 2007.
Those who ate healthy diets in 2005 were found to have fewer mental health problems than those with poor diets.
Those who improved their diets by eating more healthy foods between 2005 and 2007 also had better mental health than those who had an unhealthy diet during that period.
Other factors that could be associated with diet quality and mental health - such as the adolescent's socio-economic status, age, gender, exercise levels and weight - were also taken into account but were not found to have any effect on the results.
Dr Jacka said parents could protect children against mental health problems by following national guidelines for eating two serves of fruit and five serves of vegetables a day, as well as sticking to wholegrains and lean meats while avoiding junk food.
But she said it was also vital for government restrictions on the access to and marketing of junk foods.
"We know depression and anxiety have a very early age of onset and they are common in adolescents and it looks like quality of their diets could be linked to a risk of mental health problems," she said.
"The results suggest we shouldn't just be looking at obesity as a potential outcome of poor diet, we need to look at mental health and physical health as potential outcomes."
Dr Jacka's study was published on Thursday in the journal PLoS One.
- AAP