Defensive lineman Christian Rector's strip of Texas quarterback Sam Ehlinger at the goal line set up the game-winning kick. It was Ehlinger's second fumble and the fourth USC takeaway of the night.
The Trojans (3-0) forced the overtimes with a last-second field goal by McGrath of 31 yards, set up when Sam Darnold completed passes of 13, 18 and 21 yards, including a jump-pass under duress to running back Stephen Carr.
Darnold opened the extra frames with a first-play, 25-yard scoring strike to Deontay Burnett -- Darnold's third touchdown pass of the night and second to Burnett. The quarterback found running back Ronald Jones II for a score with the clock reading zeroes just before halftime.
Darnold finished 28 of 49 for 397 yards. He threw two interceptions, including a pick-six to safety DeShon Elliott, and was sacked three times. USC struggled to mount a rushing attack against the Texas defense, finishing with 71 yards on 37 carries.
The Texas offense had it no easier, finishing with 68 yards on 35 carries.
Texas (1-2) scored its first offensive touchdown of the game with 0:45 remaining in regulation. Ehlinger capped a 91-yard drive, which included two fourth-down conversions, by finding wide receiver Armanti Foreman for a 17-yard touchdown strike.
The Longhorns threatened earlier in the quarter, but Marvell Tell's interception snuffed out Texas' red-zone opportunity.
Ehlinger finished 21 of 42 for 298 yards and threw a touchdown pass of 3 yards to Cade Brewer in the first overtime.
Jones took a Darnold pass 56 yards for a touchdown as time expired to give USC a 14-7 halftime lead.
The entirety of the first half's scoring came in the final 2:40, with a flurry of action capping an opening two quarters defined by stingy defense and offensive miscues.
USC broke a scoreless stalemate late in the second quarter when Darnold found Burnett in the back of the end zone on a 15-yard strike. The Trojans' previous six possessions ended with two failed fourth-down conversions, including one at the goal line, a missed field goal and three punts.
In a fitting indicator of the half's flow, the lone Texas score came via defense. DeShon Elliott snagged an interception that caromed off the hands of USC wide receiver Jalen Greene and ran it back 38 yards for a touchdown.
The Longhorns came with a feisty defensive effort, paced by linebacker Anthony Wheeler, who finished the half with six tackles, three tackles for a loss and a sack. After piling up more than 300 rushing yards against Stanford, the Trojans managed just 66 yards on 24 carries by intermission.
Darnold finished the half 12-of-21 passing for 173 yards. He threw his sixth incompletion at 10:48 remaining in the half; he threw five the entire game in USC's Week 2 win over Stanford.
Sledding was not any easier for the Texas offense. Wide receiver Collin Johnson caught a 48-yard pass from Ehlinger on the Longhorns' first play from scrimmage, setting them up in scoring territory for the first and only time on the half.
The possession ended on a failed fourth-down conversion attempt. Texas' six other possession ended in two turnovers and four punts. The Longhorns surrendered three sacks on their final drive, including two to USC defensive end Porter Gustin, who had toe surgery earlier in the wee