Cincinnati scored a single run in six straight innings beginning in the second to support a 5 1/3-inning effort from Tony Cingrani.
Cingrani (7-3) returned from a stint on the disabled list brought about by a sore back and held the Cardinals to two runs on four hits with seven strikeouts.
Frazier hit his home runs in the third and seventh innings. Shin-Soo Choo added one in the fourth and Jay Bruce hit another in the fifth. Bruce also contributed an RBI single in the sixth.
St. Louis slipped 1 1/2 games behind idle Pittsburgh in the race for the National League Central title. Cincinnati, holding down third place in the division and running second in the battle for the league's two wild card spots, closed within three games of the Pirates.
Lance Lynn (13-10) suffered the loss, surrendering four runs on seven hits in five innings.