The Stars saw a 3-0 lead cut to one goal 8:35 into the third period and goaltender Marty Turco came under constant attack until Ott scored into an empty net with 9 seconds remaining.
Ott had missed four games with a rib injury. He also assisted on Trevor Daley's power-play goal midway through the second period that gave the Stars a 3-0 lead.
Dallas has played nine games and has picked up at least one point in seven of them.
The Ducks lost their second in a row and have won just once at home this season. Ryan Getzlaf scored Anaheim's first goal with 2:08 left in the second period and Joffrey Lupul brought the Ducks within one with a slapshot.
Turco made 24 saves. Jonas Hiller stopped 34 of 37 shots.