Dunn and Viciedo hit two of the game's five home runs to break open what had been a 4-4 contest.
The division-leading White Sox won their second straight after letting an early four-run lead get way.
Toronto tied it in the sixth on a three-run homer by Kelly Johnson, but Chicago stormed back in front during the next half inning.
Alejandro De Aza drew a leadoff walk off Ricky Romero (8-10), who then hit Kevin Youkilis with a pitch. Brad Lincoln came on to replace Romero and Dunn promptly hit Lincoln's third pitch over the wall for his 34th homer of the season.
A.J. Pierzynski followed with a one-out double and, with two away, Viciedo hit one out to right.
Gavin Floyd (9-9) lasted six innings to get the victory, giving up four runs on eight hits with eight strikeouts and no walks.