Barra, a 51-year-old engineer who is currently executive vice president of global product development, purchasing and supply chain, will be the first woman to lead a major automaker.
"I'm honoured to lead the best team in the business and to keep our momentum at full speed," she said in a statement.
GM said that the 65-year-old Akerson, who is both chairman and CEO, decided to move up his retirement after his wife was diagnosed with advanced cancer.
The company designated board member Theodore (Tim) Solso to succeed Akerson as chairman.
The announcement comes a day after the US government sold all of its remaining shares in GM, which brings to an end a phase in the history of the largest US carmaker that began in 2009 with the injection of $50 billion in public funding.
Akerson took over GM in September 2010, a year after the company emerged from bankruptcy reorganisation.
"I will leave with great satisfaction in what we have accomplished, great optimism over what is ahead and great pride that we are restoring General Motors as America's standard bearer in the global auto industry," the outgoing boss said in a message to GM employees.
Mark Reuss, president of GM North America, will replace Barra as executive vice president for global product development.