The performer - better known for his flamboyant character Lily Savage - is due to play a bingo caller in Eyes Down.
It will be the first non-costume acting role for O'Grady, who left hospital on Wednesday after being taken ill on 19 April.
BBC producers are confident he will make a speedy recovery so he can start work on the programme later this year.
A spokeswoman said: "We wish him a healthy recovery but because we are not due to start filming until late in the year, it is not an issue for us.
"His character is very sarcastic and quite domineering so he is not particular popular with the staff and punters. It is a show we thought he would be fantastic in."
The six-part series has been commissioned from a script by Angela Clark, who won a BBC Talent competition for new writers.
Details were announced at the Montreux Television Festival in Switzerland.
Other programmes announced include a new comedy starring Harry Enfield and Amanda Holden, called Celeb.
Enfield plays an ageing rock star, while Holden is his publicity-hungry wife.
One-off specials of Alistair McGowan's Big Impression are planned to mark the World Cup and Golden Jubilee, while Dawn French will star in a new sitcom, Wild West, set in a Cornish post office.
A second series of Bedtime, starring Sheila Hancock and Timothy West, is also planned.