Walsh, 29, had been scheduled to play Princess Fiona from December but is taking over two months earlier than planned because Holden is pregnant.
Holden, who lost a baby in February seven months into her pregnancy, will leave the show on 3 October with Walsh starting two days later.
The musical, based on the 2001 film, opened in London's West End in June.
Holden, 40, and her husband Chris Hughes announced on Wednesday they were expecting a girl.
The Cutting It actress went to hospital in February after her baby son stopped moving. He was later stillborn.
"The first half of this year has been unbelievably difficult for us," said Holden, adding that she and her husband were "beyond thrilled" to share the news.
The role in Shrek marks a West End return for Walsh, who made a cameo in Les Miserables as part of 2008 TV series The Passions of Girls Aloud.
Nigel Lindsay and Richard Blackwood will remain in their roles in the show at the Theatre Royal Drury Lane, currently booking until October 2012.