Three people were seriously hurt and one suffered minor injuries in the attack in Wuerzburg, police said.
Initial reports said up to 20 people had been injured but it was later revealed that at least 14 had been treated for shock.
The motive for the attack is not yet clear.
Bavarian Interior Minister Joachim Herrmann said the attacker was a 17-year-old Afghan refugee who had been living in the nearby town of Ochsenfurt.
He told public broadcaster ARD that the teenager appeared to have travelled to Germany as an unaccompanied minor.
The incident happened at about 21:15 (19:15 GMT) on the train which runs between Treuchlingen and Wuerzburg.
“Shortly after arriving at Wuerzburg, a man attacked passengers with an axe and a knife,” a police spokesman said.
Police said the attacker fled the train but was chased by officers who shot him dead.