Federal police say no humans were injured in the incident near Freiburg at 4:30 a.m. Monday.
Their investigation quickly pointed to two dogs seen at the site - and officials found that at least one sheep had been bitten to death by the animals.
The dogs' attack prompted the sheep to break out of their pen in a panic, running toward a railway line and the oncoming train. The driver hit the brakes but couldn't avoid the sheep.
Police said the dogs - a husky and a mongrel - already had attacked sheep nearby in January. Their owners face an investigation and likely damages claims.