The go-ahead score came at the end of 75-yard drive with the clock winding down and the Longhorns (4-0, 1-0 Big 12) trailing 36-34.
The key play was a desperation fourth-and-6 attempt on which David Ash hooked up with D.J. Grant for a 29-yard gain to the Oklahoma State 42.
Bergeron's touchdown run with 29 seconds left was reviewed by the officials after it seemed he had lost the ball in a goal-line pileup, but the score was ultimately upheld.
Ash finished 30-of-37 passing for 304 yards and three touchdowns -- all to Jaxon Shipley, who made five grabs overall for 82 yards.
J.W. Walsh completed 18-of-27 passes for 307 yards, two scores and a pickoff for the Cowboys (2-2, 0-1).