The score was tied 2-2 in the fifth when Garrett Jones singled and Neil Walker drew a two-out walk, bringing up Alvarez, who hammered a 3-2 pitch into the center field batter's eye for a decisive shot.
Jones provided a two-run double and Alex Presley went 3-for-4 with a solo homer for the Pirates, who took two-of-three from the Dodgers and notched a sixth win in nine games overall.
Former first-round pick Cole (2-0) posted his second win in two starts since his debut last week, holding the Dodgers to three runs on seven hits over 5 2/3 innings.
Los Angeles starter Zack Greinke (3-2) went just five innings, coughing up five runs on eight hits.
Andre Ethier drove in a pair of runs and Yasiel Puig added three hits for the Dodgers.
Boston schools pull out free condoms over wrapping complaints
Aaron Carter is still in love with Hilary Duff