Kozma's three-run double in the second inning erased an early 2-0 deficit and Carpenter broke a 3-3 tie with a run-scoring single in the seventh for St. Louis, which claimed the rubber match of a three-game series.
Seth Maness (4-1) was credited with the victory in relief of starter Shelby Miller, who was touched for three runs on seven hits over 5 1/3 innings.
Trevor Rosenthal hurled 1 2/3 scoreless innings and Edward Mujica notched his 14th save for National League Central-leading St. Louis, which recorded a fourth win in five games overall.
LA's Clayton Kershaw (5-3) was the loser, yielding four runs on seven hits over seven innings. The Dodgers ace issued three walks and struck out five.
Adrian Gonzalez went 2-for-4 with a two-run homer and an RBI single for Los Angeles.