The Messenger of Allah, sallallahu `alaihi wa sallam, said: "The master of invocations for forgiveness is that the servant says:
'Allãhumma 'anta rabbee, lã 'ilãha 'illã 'anta, khalaqtanee, wa 'anã `abduka, wa 'anã `alã `ahdika wa wa`dika mastata`tu, 'a`outhu bika min sharri ma sana`tu, 'aboo'u laka bini`matika 'alayya, wa 'aboo'u bithambee, faghfirlee fa'innahu lã yaghfiru 'aththunooba 'illã 'anta.
O' my 'ilãh You are my Lord, there is no 'ilãh but You. You created me, and I am your bondservant, and I will stick to my covenant and promise [of faith and sincere obedience] to You, as to my ability. I seek refuge in You from the evil of what I have done, I acknowledge, to You, your bounties upon me, and I acknowledge, to You, my sin. Thus forgive me, for none forgives sins except You.
Whoever says this as he enters upon evening, then, dies that night, he would enter Paradise; and if one says this as he enters upon morning, then, dies that day, he would enter Paradise". [Al-Bukhari]
The servant is always in the blessings of Allah which necessitate thankfulness, and in sinfulness which requires seeking forgiveness. Both of these matters are required and essential for the servant at all times, as the servant does not cease to alternate between Allaah's (various) favors and blessings, and does not cease to be in need of repentance and seeking forgiveness.
This is why the Master of the Children of Adam, and the Leader of the Pious, Muhammad, sallallahu `alaihi wa sallam sought forgiveness in all circumstances. He said in an authentic hadeeth reported by al-Bukhari: "O people, repent to your Lord, for verily I seek forgiveness from Allah and repent to him more than seventy times in a day."
It is reported in Saheeh Muslim that he said: "I seek forgiveness one hundred times in a day." [Muslim]
`Abdullah ibn `Umar said: We counted in a single sitting the Messenger of Allah, sallallahu `alaihi wa sallam, saying one hundred times: "Rabbi-ghfir-lee wa tub `alayya innaka anta-t-tawwabu-l-ghafoor." [My Lord, forgive me and accept my repentance, verily you are Acceptor of Repentance, Oft-Forgiving.] [Ahmad, Abu Dawood, Ibn Maajah]
This is why seeking forgiveness was legislated at the end of actions. Allah the Exalted said: "Those who seek forgiveness before dawn (at late night)." [Aal `Imraan (3):17] Some of them said: "Give life to your nights by performing Prayer, and when the time of late night comes, concern yourself with seeking forgiveness."
It is related in the Saheeh that the Prophet, sallallahu `alaihi wa sallam, when he finished his Prayer, he would seek forgiveness three times and say: "Allãhumma 'antas-salamu, wa minkas-salãmu, tabãrakta yã thaljalãli wal 'ikrãmi." [O' my 'ilãh You are 'As-Salãm [One free from flaws], and from You comes Salãm [peace, or safety], blessed are Thee O' haver of glory and kindness.] [Muslim]
Allah says: "And seek forgiveness of Allah. Indeed, Allah is Forgiving and Merciful." [al-Muzammil (73):20] (Even) After the Prophet conveyed the Message, fought in the path of Allah with true jihad, and performed what Allah ordered more than anyone else, Allah commanded his Prophet (to perform istighfar), as He the Exalted said:
"When the victory of Allah has come and the conquest, and you see the people entering into the religion of Allah in multitudes, then exalt [Him] with praise of your Lord and ask forgiveness of Him. Indeed, He is ever Accepting of repentance." [An-Nasr (110):1-3]
This is why the Deen is established with Tawheed and Istighfaar, as Allah the Exalted said: "Alif Lam Ra. [This is] a Book whose verses are perfected an then presented in detail from [one who is] Wise and Acquainted. [Through a messenger, saying], "Do not worship except Allah. Indeed, I am to you from Him a warner and a bringer of good tidings," and [saying], "Seek forgiveness of your Lord and repent to Him, [and] He will let you enjoy a good provision." [Hood (11):1-3]
And Allah says: "So take a straight course to Him and seek His forgiveness." [Fussilat (41):6]. And He says: "So know [O Muhammad], that there is no deity except Allah and ask forgiveness for your sin and for the believing men and believing women." [Muhammad (47):19]
This is why it was it came in a narration: "The Shaytan said: People are destroyed with sins, and they destroy me with 'Laa ilaha ill Allah' and seeking forgiveness." [Reported by Ibn Abi Asim and Abu Ya`la, but its chain is a fabrication] . Yoonus, `alayhis salam, said: "There is no deity except You; exalted are You. Indeed, I have been of the wrongdoers." [al-Anbiyaa' (21):87]
The Prophet, sallallahu `alaihi wa sallam, when he would ride his mount, he would praise Allah, then say Allahu Akbar three times, then say: "Lã 'ilãha 'illa 'anta subhãnaka, thalamtu nafsee, faghfirlee." [I testify that there is no 'ilah except You, Glorified are You, I have transgressed upon myself, so forgive me] [Abu Dawood and at-Tirmidhi, who said it is hasan saheeh]
Expiation of a gathering with which the gathering is completed is (the supplication):"Subhãnaka 'allãhumma wa bihamdika, 'ash-hadu 'an lã 'ilãha 'illa 'anta, 'astaghfiruka wa 'atoobu 'ilayka." [Glorified are You O' my 'ilãh and I am in Your praise, I testify that there is no 'ilah except You, I ask Your forgiveness and repent unto You.] [Abu Dawood and At-Tirmidhee, who said it is hasan saheeh]
Allah knows best, and may His blessings and peace be upon [the Prophet] Muhammad.
REPRODUCED here from http://www.central-mosque.com/fiqh/astaghfaar.htm