The defender made his first appearance since last November after coming on with 16 minutes to play as Joseph-Claude Gyau netted the winner to seal the friendly win
The Serbian defender has been out of action since suffering a cruciate ligament injury in a 2-1 defeat to Wolfsburg last November.
But the 25-year-old came on with 16 minutes left to play on Saturday, replacing Evans Nyarko in the centre of the Dortmund back four.
And Subotic was able to celebrate a victory on his return as Jurgen Klopp's men came out on the right side of a seven-goal thriller.
Gabonese forward Pierre-Emerick Aubameyang put visitors Dortmund ahead after 21 minutes, only for strikes from Florian Niederlechner and former Schalke player Robert Leipertz to give Heidenheim a 2-1 lead at half-time.
A second-half double from Dortmund attacking midfielder Henrikh Mkhitaryan, sandwiching an effort from Heidenheim forward Patrick Mayer, left the match finely poised at 3-3 heading into the closing stages.
It was Dortmund that had the benefit of the game's final twist, though: 21-year-old American Joseph-Claude Gyau popping up in the 85th minute to seal triumph.