Maliks Muwatta Book 20, Hadith Number 117.
Yahya related to me from Malik from Hisham ibn Urwa that his father would never do two sets of seven tawafs together without praying between them. After every seven tawafs he would pray two rakas, sometimes at the maqam of Ibrahim, and sometimes elsewhere.
Malik was asked whether a man doing voluntary tawaf could, to make it easier on himself, join two or more sets of seven circuits and then pray whatever he owed for those sets of seven, and he said, “He should not do that. The sunna is that he does two rakas after every seven circuits.”
Malik said, about someone who began doing tawaf and then forgot how many he had done and did eight or nine circuits, “He should stop when he knows that he has done more than the right number and then pray two rakas, and he should not count the ones that he has done in excess. Neither should he build on the nine that he has done and then pray the rakas for the two sets of seven circuits together, because the sunna is that you pray two rakas after every seven circuits.”
Malik said that someone who was in doubt about his tawaf after he had prayed the two rakas of tawaf should go back and complete his tawaf until he was certain of how much he had done. He should then repeat the two rakas, because prayer when doing tawaf was only valid after completing seven circuits.
“If some one breaks his wudu either while he is doing tawaf, or when he has finished tawaf but before he has prayed the two rakas of tawaf, he should do wudu and begin the tawaf and the two rakas afresh. Breaking wudu does not interrupt say between Safa and Marwa, but a person should not begin say unless he is pure by being in wudu.”