The Dodgers won their fourth in a row and Arizona lost its sixth straight.
Ethier hit his 11th homer of the year in the fourth, a two-run shot that put the Dodgers in front. Los Angeles was clinging to a 3-2 advantage in the seventh when Ramirez, who was taken off the disabled list last weekend, doubled to deep center with the bases loaded.
Hiroki Kuroda (4-1) picked up the victory, giving up two runs on six hits in 7 1/3 innings. He struck out nine.
Adam LaRoche drove in all of Arizona's runs on a two-RBI double in the fourth and a sacrifice fly in the eighth.
Los Angeles has overcome a slow start to the season to reach the .500 mark.
Millions of Getty images now available for free via embed tool
Boston schools pull out free condoms over wrapping complaints