Francisco Liriano befuddled the Brewers with his slider over the first three innings before Ramirez sent a 1-2 fastball over the left-field wall for a 2-0 lead.
At 8-2 on the year, the Brewers are off to their best start since opening with 13 wins in 1987.
Peralta (1-0) allowed four hits in seven innings, but gave up a two-run homer to Neil Walker in the seventh.
Francisco Rodriguez struck out the side in the ninth for his third save.
Liriano (0-2) struck out seven over six innings. He also gave up a homer in the fifth to Mark Reynolds.