The tourists, who resumed on 178 for two overnight, were dismissed eight minutes before tea. The England skipper departed when he edged Ashwin to Dhoni who later caught Pietersen off Ojha in the second hour after lunch.
Cook's departure before lunch triggered a collapse in which seven wickets fell in quick succession.
Once the Cook-Pietersen partnership was broken, Ojha got into his wicket taking act with a spell of three for 52 on either side of lunch during which he sent back Jonny Bairstow (9), Samit Patel (26) and Pietersen, who struck 21 fours and four sixes in his 233-ball knock in 317 minutes.
Ojha had accounted for Nick Compton and Jonathan Trott yesterday. But Pietersen was especially harsh on Ojha who foxed him twice at Ahmedabad.
Image: Ashwin celebrates the dismissal of Alastair Cook with team mates during the third day of the second test on Sunday.