Pena finished 2-for-4 with a pair of RBI in the designated hitter spot while Xavier Nady drove in three runs for the Diamondbacks, who have won seven straight on the road and were coming off a three-game sweep of the Royals in Kansas City.
Esmerling Vasquez (1-1) recorded the win after tossing a one-hit seventh for Arizona.
Reliever David Purcey (1-1) was charged with the loss after giving up the late home run to Pena.
The Diamondbacks took their first lead of the game with two outs in the eighth when Purcey left a pitch high in the zone and Pena scorched it just under the scoreboard behind the left field seats to make it 7-6.
The Tigers scored in the first inning with the bases loaded and two down when Peralta belted a ball off the top of the fence in left for a two-run double.
The lead was pushed to 4-0 in the third inning. Wells and Magglio Ordonez ripped back-to-back doubles to score the first run. Later in the inning, Ordonez came home when Victor Martinez's sharp grounder deflected off shortstop Stephen Drew's glove.
Drew hit a sacrifice fly to score Johnson and Nady drilled a grounder up the middle, plating Upton to halve the deficit. Pena then singled in Young to make it a 4-3 game.
Detroit played keep-away in the bottom of the inning with Wells' two-run homer over the left fence to extend the lead to 6-3.
Arizona, though, came right back in the fifth. With the bases jammed and two outs again, Nady hit a two-run single to right to cut it back to a one-run game.