Esmerling Vasquez relieved Scherzer and, with runners on first and second, got Matt Kemp to line out to left to end the inning. Scherzer also went 7 2/3 innings against San Francisco in June.
Juan Gutierrez worked a perfect ninth for his second save.
Los Angeles saw its lead in the National League West reduced to 4 ½ games over Colorado.
Arizona scored all its runs in the fifth against LA starter Chad Billingsley (12-9). Miguel Montero doubled with one out and scored on Allen's second homer of the season.
Alex Romero kept the inning going with a base hit and moved to third on a two-out single by Scherzer. Stephen Drew then reached on an infield single and Romero scored when shortstop Rafael Furcal threw wildly to first.
Another single by Gerardo Parra brought in Scherzer with the fourth run of the inning.