The Braves broke a 2-all tie with two runs in the sixth inning off rookie Shelby Miller (10-7) and two relievers. Pinch-hitter Joey Terdoslavich drove in Chris Johnson with the go-ahead run. Heyward added another run-scoring single.
Heyward has nine homers this season, including two in the series between NL division leaders.
Kris Medlen (7-10) allowed two runs on eight hits and a walk in six innings to snap his three-game losing streak.
Miller allowed three runs, two earned, on six hits and two walks in 5 2-3 innings.
The Braves finished their first three-game sweep of the Cardinals at Turner Field since April 22-24, 2003.
Atlanta relievers Luis Avilan, Jordan Walden and Craig Kimbrel combined for three scoreless innings. Kimbrel pitched a perfect ninth to take the NL lead with his 31st save.
The Cardinals, who lead the NL in batting average and runs, were held to three runs in the series.
Johnson singled with two outs in the second, moved to third when the ball bounced past Carlos Beltran in right field for an error, and scored on a single by Andrelton Simmons. Heyward's line-drive homer to the front row in right field pushed the lead to 2-0 in the third.
Heyward hit leadoff for the second straight night.
The Cardinals pulled even with two runs in the fifth. Back-to-back doubles by Pete Kozma and Miller produced the first run.
With two outs, Beltran hit a fly ball to left field that fell between Evan Gattis and Simmons, who sprinted into the outfield from his shortstop position. Gattis, a natural catcher, was playing deep for the power-hitting Beltran and was slow to break on the ball.
The Braves' two-run sixth began with two outs. Johnson, who entered the night tied with Cardinals catcher Yadier Molina for the NL lead with a .332 batting average, singled for his second hit and moved to third on Simmons' second single. Terdoslavich and Heyward followed with run-scoring hits.
Johnson added his third hit, a double, off Fernando Salas in the eighth to push his average to .338. Johnson scored on an infield hit by Reed Johnson and a throwing error by Kozma from shortstop.
Reed Johnson pulled up with an apparent injury after running to first and was replaced by pinch-runner Jose Constanza.
The Braves made two strong defensive plays. Simmons went to his right, falling to his knees, to snag a grounder by David Freese before throwing to second to start a double play in the second. Freddie Freeman leaned over the railing in front of the Atlanta dugout to catch a foul popup by Matt Holliday to end the eighth.
NOTES: Cardinals GM John Mozeliak said the team is ''not close to doing anything'' before Wednesday's trade deadline. Mozeliak said he is reluctant to trade prospects ''for short-term gain.'' ... The Cardinals were swept in a road series for the first time this season. ... Molina had two hits, leaving his average at .334. ... The Braves' last three-game sweep of the Cardinals was May 11-13, 2012, at St. Louis. ... Braves RHP Brandon Beachy, returning from Tommy John surgery, will make his first start of the season Monday night when he faces Colorado's Jorge De La Rosa. The Cardinals open an important NL Central series at Pittsburgh when Jake Westbrook faces Francisco Liriano.
Link to box score: Atlanta 5, St. Louis 2
Link to game discussion at The Cardinal Nation message board