Andersen replaces Mike Riley, who left the Beavers this month after 14 seasons to take the head job at Nebraska.
Oregon State announced the news on Twitter on Wednesday afternoon.
- Beavers Football (@OSUBeaversFB) December 10, 2014
Wisconsin athletic director Barry Alvarez said in a press conference Wednesday evening that he was "very surprised" by the news. "I really had no idea this was in the works," he said.
Alvarez said family considerations motivated Andersen's decision.
"I thought Gary was a good fit," Alvarez said. "There was never any talk about, 'Someday I'd like to get back to that part of the country.' When you're away for a while, maybe that settles in. I don't know that. Those are things you may want to ask him."
Andersen's comments were limited to a statement thanking Wisconsin for the opportunity. "We worked very hard together and accomplished some great things. I had the opportunity to meet and coach some great young men and I look forward to watching them as they continue their careers and move through life," he said.
Oregon State will introduce Andersen as the 28th coach in team history at a news conference Friday. The announcement of his hiring came the same day Oregon State announced extensive renovation plans for its football facilities.
"We have hired the right coach," Oregon State athletic director Bob De Carolis said. "We are investing in the new and expanded facilities he needs, including the $42 million makeover of the Valley Football Center. We are ready to have Gary take us to the next level."
Oregon State finished this season 5-7 and out of the postseason picture.
Alvarez said he wants to have a new coach in place at Wisconsin by Jan. 1. He said he is looking for someone with head-coaching experience, but the candidate doesn't need to have Wisconsin ties.
"My phone is ringing off the hook already," Alvarez said. "Word is just starting to leak out, and I'll be very busy tonight answering phone calls from agents and coaches.
"I'll try to make contact with people ... and try to move as quickly as we possibly can through our system and the process we have to follow," he said. "My goal would be to have somebody in place certainly before the bowl game."
Wisconsin plays Auburn in the Outback Bowl on New Year's Day. Alvarez will coach the Badgers in that game.
Wisconsin star running back Melvin Gordon, a Heisman finalist who announced his intention to enter the NFL draft earlier in the day, weighed in on the news at the ESPN Home Depot College Football Awards Show on Wednesday night.
"I was shocked," Gordon said. "Didn't see it coming. Thought he'd be there a long time ... He seemed happy. He was smiling. I saw no sign of this."
WOW !!!— Gordon | 25™ | A01 (@Melvingordon25) December 10, 2014
Gordon, who spoke to Andersen earlier in the evening, said of their conversation, "He said he had to do what was best for him. He sounded hurt. I heard hurt in his voice."
Andersen was 19-7 in two seasons with the Badgers. Prior to going to Wisconsin, Andersen compiled a 26-22 record in four seasons as head coach at Utah State, including an 11-2 record in 2012 when he was named WAC Coach of the Year.
"He has extensive West Coast ties and knows the landscape of the Pacific-12 Conference, having previously coached at Utah, a current conference member. He is part of the Urban Meyer coaching tree," De Carolis said. "He and his staff will teach offense and defense, and life lessons about values and character. They will guide our student-athletes to success in life and careers upon leaving Oregon State."
The Associated Press contributed to this report.