A presidential spokesman said Oli, who spent 14 years in jail for opposing the now-abolished monarchy in the 1970s and 1980s, was named Prime Minister hours after Sher Bahadur Deuba, whose party suffered a landslide defeat in the polls, resigned.
Oli was also prime minister from 2015 to 2016, soon after the nation's current constitution was formalized.
Oli's alliance is considered to be closer to China while outgoing leader Deuba is widely seen as being closer to India.
India and China have poured aid and investment to woo Nepal, home to Mount Everest, as a geo-political ally.
"Oli is going to be pragmatic as prime minister to balance India and China," said Kunda Dixit, editor of the weekly Nepali Times.
Nepal held parliamentary elections in November and December but the formation of the new government had been delayed because the Election Commission declined to declare the final results until the election of the upper house of parliament, which was held last week.
"He has already received the appointment letter from the president," Bhandari's spokesman, Kul Prasad Chudal, told Reuters.
Oli is to take the oath of office later on Thursday, Chudal said. Nepal has been embroiled in political instability since a decade-long Maoist conflict ended in 2006 and the monarchy was abolished two years later. Oli is the 26th prime minister since protests led to the establishment of a parliamentary democracy in 1990.
Oli has said he will promote peace, stability and development in one of the world's poorest countries where revolving-door coalitions have sapped business confidence, curbed growth, spurred corruption and slowed reconstruction after a 2015 earthquake that killed 9,000 people.
The new government will be faced with an economy plagued by dwindling exports, manufacturing and remittances.
Party officials said Maoist chief Prachanda will take over from Oli as Prime Minister before his five year term expired under a power sharing deal.