Martinez (2-0) gave up four hits and walked two in the longest of his three starts this season. Jordan Walden pitched eighth and Trevor Rosenthal finished for his seventh save in seven tries, completing a five-hitter.
Heyward belted a solo shot off Matt Garza in the third, lifting St. Louis to a 2-0 lead. Peralta homered leading off the sixth.
Garza (1-3) allowed seven hits in six innings while striking out a season-high six.