Kevin Durant, the Big 12's leading scorer and rebounder, put Texas on top with a three-point play with 10.5 seconds left, but there was still time for Boggan.
He took the ensuing inbounds pass near midcourt and fought through defenders to launch a 3 from the left wing. He fell to the floor and was joined by celebrating teammates after Texas' A.J. Abrams was called for traveling with 0.2 seconds left to clinch the win for the Cowboys.
Boggan entered the game 5-for-33 from 3-point range this season.
JamesOn Curry added 28 points and nine rebounds, Terrel Harris scored 16 points and Byron Eaton had 11 for Oklahoma State (16-2, 2-1 Big 12), which also won a double-overtime game against Pittsburgh earlier this season.
Durant, a freshman, tied his career best with 37 points and had 12 rebounds for the Longhorns (13-4, 3-1). D.J. Augustin added 19 points, Justin Mason had 18, Abrams 13 and Damion James had 10 points and 11 rebounds.
Oklahoma State scored the first five points of the third overtime but Texas tied the game at 100 on Connor Atchley's 3-pointer from the left corner.
Curry followed with two free throws to make it 102-100 and the teams both had empty possessions before Texas got the ball with 18 seconds to play.
A.J. Abrams drove the lane, and Durant was able to grab his missed runner and put it back while getting fouled by David Monds. He stepped to the line and drilled his free throw to give Texas the short-lived lead.
Fans rushed the court after the game finally ended - a rare sight at Gallagher-Iba Arena, where the Cowboys rarely lose.
Texas kept staying alive largely because of Durant.
He helped lead the Longhorns back from a five-point deficit in the final minute of regulation, scored seven points in the first overtime and made two crucial defensive plays to force the third extra period.
Durant and Augustin sandwiched 3-pointers around a free throw by Curry to tie the game at the end of regulation, and neither team led by more than two points in the first overtime.
Texas stayed alive when James blocked a shot in the lane by walk-on Tyler Hatch, and Durant tied it with a jumper from the right elbow with 25 seconds left. Augustin then answered Monds' alley-oop jam with a driving layup with 12 seconds left to force a second overtime.
The Cowboys led 89-84 in the second overtime after Boggan missed a 3-pointer and a jumper on the same possession, then turned his third chance into a three-point play by driving to the basket for a layup.
Texas rallied to tie the game at 91 on Durant's 3-pointer from the right wing with 1:02 left, and the Cowboys went up again when Boggan found Hatch for a layup on their next possession. It could have been 95-91, but Cowboys coach Sean Sutton called a timeout after Hatch missed his chance for a three-point play and before Boggan banked in the offensive rebound.
That opened the door for Durant and the Longhorns.
The 6-foot-9 freshman blocked Monds' 3-point shot and then rushed downcourt for a two-handed jam to tie the game at 93. He then tied up Monds near halfcourt on the Cowboys' ensuing possession, giving Texas the ball back with 5 seconds left. Durant's potential game-winning 3-pointer from the left wing was off-target, and the game continued.
Texas hadn't played a double-overtime game since 1995, and hadn't played three extra periods since it lost 95-94 to TCU in four overtimes on Jan. 7, 1961, in the longest game in Southwest Conference history.
Oklahoma State hadn't played more than two overtimes since winning 96-91 at Colorado on Feb. 5, 1983.