The news was announced after Mayo, who had been the voice of Drivetime for eight years, announced he was leaving – following just a few months co-presenting with Whiley.
Cox had lost out to Zoe Ball for the breakfast programme, and was the favourite to take over the 5pm-8pm slot.
"I've been proud to be part of the Radio 2 family for a few years now," Cox said in a statement. "The opportunity to present such a big show as Drivetime – playing fantastic music and hopefully making people smile as they cook tea or head home after a day's graft – is the icing on what is already a brilliant cake.
"I'm beyond chuffed to be given this role," she added.
The BBC has not yet announced when Cox, who is currently the presenter for Radio 2's 10pm-midnight show Monday to Thursday, will begin her new role on Drivetime.
Before joining the BBC in 1999, she worked on Channel 4's The Big Breakfast, MTV and various other shows. She first appeared on Radio 2 in 2011, and has stepped in to host the Radio 2 breakfast show when Chris Evans has been away in recent years. In 2013, she got her own show on Radio 2 by launching Sounds of the 80s, which she hosted until earlier this year.
Mayo recently denied that his decision to quit had anything to do with Whiley joining the show, following a report in The Sun that claimed he was leaving after being “forced” to work with her.
The DJ, who has hosted Drivetime since 2010, said he “loved” working with Whiley and added she had been his “first and only” choice when the show was reconfigured.
“Juggling my writing and radio has become increasingly tricky (a nice problem to have),” Mayo said. “I've just signed a new 2 book deal with the nice folk at Transworld and they'll be expecting something half decent before too long.
Access unlimited streaming of movies and TV shows with Amazon Prime Video Sign up now for a 30-day free trialSign up
“I know, I know, I'm as surprised at this turn of events as you. But at my grand old age to be setting off on these brand new trails is enormous fun. And all the more so for being so unexpected. There are, however, only so many hours in a day.”
Addressing reports of a rift between himself and Whiley, he added: “One other thing. maybe it needs to be said, maybe not but there is no room for argument so I'll be clear. I've loved working with the exceptional Jo Whiley and when the show was 'reconfigured' she was my first and only choice.
“Some of the abuse she has had here has been appalling. Support for a show is one thing, assaulting the dignity of a warm-hearted and loyal friend is another. So by all means discuss what's happening here, but let's keep some civility. Here endeth the lesson.”
Whiley is also leaving the Drivetime show, moving to a 7pm-9pm, Monday to Thursday slot to present a new music show.
Responding to Mayo's departure, she said: “I'm incredibly sad that Simon has decided to leave Radio 2. He's a brilliant broadcaster, a great friend and I really will miss working with him.”
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies