Dench will play Queen Margaret, one of the few Shakespearean roles she has yet to perform.
The Telegraph reports that Cumberbatch had approached Dench several months ago about co-starring in the production. When audiences were invited to participate in the discussion, he repeated his query from the front row of the audience.
Cumberbatch asked Dench, "Would you like to be in Richard III with me?" and she replied, after a long pause, "Yeah."
Dominic Cooke, former artistic director of the Royal Court, will direct the production. It is the concluding part of The Hollow Crown, a series of Shakepeare history plays for the BBC, which began in 2012.
During the master class, Dench gave performances from Antony and Cleopatra and Twelfth Night, with Cumberbatch playing Orsino to her Viola.
Dench's stage work includes Amy's View, King Henry V and Twelfth Night. Her film work includes "Notes on a Scandal," "Iris," "Chocolat," "Skyfall" and "Shakespeare in Love."
An Olivier Award winner, Cumberbatch's stage credits include the National Theatre's 2011 production of Frankenstein and 50 Years on Stage. He will star in Hamlet at the Barbican Theatre in August 2015.
Cumberbatch stars in the TV show "Sherlock," and his film credits include "August: Osage County," "The Fifth Estate" and "12 Years a Slave."