The star is best known for playing Q in Bond film Skyfall and newshound Freddie Lyon in BBC drama The Hour.
He replaces Sacha Baron Cohen, who pulled out of playing Mercury in July citing "creative differences".
The Queen singer died in 1991. The film, which will be directed by Dexter Fletcher, will follow the band in the run-up to Live Aid in 1985.
Queen guitarist Brian May and drummer Roger Taylor will oversee the soundtrack, which will include hits like Bohemian Rhapsody and We Will Rock You.
The film will be written by Peter Morgan, whose other screenplays include James Hunt biopic Rush and the Oscar-nominated Frost/Nixon and The Queen.
Whishaw, 33, is currently filming Ron Howard movie The Heart Of The Sea opposite Chris Hemsworth, and is expected to reprise his role as gadget master Q in the next James Bond film, to be released in 2015.
Dexter Fletcher, meanwhile, is known for acting in Lock, Stock and Two Smoking Barrels, Kick-Ass and 1990s ITV drama Press Gang before moving behind the camera to direct Sunshine On Leith, based on the music of The Proclaimers.
James Bond actor Ben Whishaw is to play Freddie Mercury in a new film about rock band Queen.