Detroit ended a six-game losing streak, during which the Red Wings managed only seven goals.
Alfredsson scored just 26 seconds into the contest and also assisted on a goal by Joakim Andersson midway through the second period.
Those two goals were not enough to prevent overtime, but Alfredsson ended the extra period with his blast that beat Karri Ramo. The winning goal came with T.J. Brodie in the penalty box for hooking.
Jonas Gustavsson made 20 saves for the victory. Ramo stopped 35 shots.
Calgary fell to 1-1-2 on a five-game road trip that will end on Saturday in Pittsburgh. The Flames' goals came from Mikael Backlund and Mark Giordano.