David Backes also scored and Jaroslav Halak made 30 saves for the Blues, who snapped a four-game road losing streak.
Dennis Wideman scored for Florida and Tomas Vokoun stopped 26 shots.
The Blues scored the go-ahead goal at 16:00 of the third period. Florida turned the puck over at the blue line, giving St. Louis a 3-on-1 as it came down the ice. D'Agostini's wrister went high into the net to make it 2-1.
The Blues tied it at 1 with a minute left in the second.
The Panthers turned the puck over at their own blue line and Brad Boyes grabbed it and passed to Andy McDonald along the side boards. McDonald brought the puck through the left circle toward the net, then passed it to Backes in front, who easily beat Vokoun with a wrist shot for his 18th goal of the season.
Florida took a 1-0 lead on a 5-on-3 power play in the first. Steven Weiss fed the puck to Wideman above the left circle and his one-timer beat Halak at 6:45.
The Panthers nearly went up by two goals at 8:11 of the second but a shot by David Booth hit the left post.
NOTES: Florida LW Cory Stillman sustained an upper-body injury in practice Monday. ... The Panthers recalled RW Michal Repik from Rochester of the AHL. Repik had played in eight games for the Panthers this season, recording one goal and one assist. ... Vokoun had won his last nine games (eight starts) against St. Louis. ... Halak returned after missing two games with an upper-body injury. His previous start was Jan. 24 against Colorado. ... Halak is 6-1-0 against the Panthers.