Kasay's go-ahead 37-yarder with 39 seconds left followed a 23-yard touchdown pass from Matt Moore to David Gettis that produced a 20-20 tie with 1:53 remaining.
The game-winning kick was set up by an interception by cornerback Richard Marshall, who picked off back-up 49ers quarterback David Carr.
Moore completed 28-of-41 passes for 308 yards and two scores -- both to Gettis -- with one interception for the Panthers (1-5). Gettis finished the game with eight catches for 125 yards and Brandon LaFell added six grabs for 91 yards.
Carr went 5-of-13 passing for 67 yards after entering the game to replace Alex Smith, who suffered a sprained shoulder early in the third quarter. Smith had struggled before the injury, going just 9-of-19 through the air for 129 yards and a score.
Frank Gore picked up 102 yards on 19 carries for San Francisco (1-6).
Celebrity Families of 2014 [PHOTOS]