The key to controlling thoughts during prayer is to attack the wandering mind immediately. The moment you detect a stray thought, rise up, be strong and snuff it out. Be firm and aggressive. As we said before, it takes much effort.
Here is more advice from Saint Theophan:
Kindly read the 19th discourse, concerning a Christian’s duty to force himself to do good. There it is written, “One must force oneself to pray, even if one has no spiritual prayer.” And, “In such a case, God, seeing that a man earnestly is striving, pushing himself against the will of his heart (that is, his thoughts), He grants him true prayer.” By true prayer, St. Macarius means the undistracted, collected, deep prayer that occurs when the mind stands unswervingly before God. As the mind begins to stand firmly before God, it discovers such sweetness, that it wishes to remain in true prayer forever, desiring nothing more
I have stated more than once exactly what efforts must be made: Do not allow your thoughts to wander at will. When they do involuntarily escape, immediately turn them back, rebuking yourself, lamenting and grieving over this disorder. As St. John of the Ladder says, "We must lock our mind into the words of prayer by force."
When you have learned the prayers by heart, as I suggested in my earlier letter, perhaps then you will progress more smoothly.
The most helpful idea is to attend church frequently. There, prayers come more readily because all is directed to that end, but this is not very practicable for you. So, labor at home to accustom yourself to pray attentively and try to remain in God’s presence the rest of the time, as much as possible.
When memorizing the prayers, do not forget to dig into the meaning and to experience the feeling in each word. Then when you say the prayer, the words themselves will hold your attention and warm you into a prayerful attitude.
from Letter 48