According to the majority of the Scholars, the supplication for Istikhaarah should be done after the prayer due to the use of the word (ثُمَّ ) ‘then’ in the Hadith of Jabir (may Allah be pleased with him) :
إِذَا هَمَّ أَحَدُكُمْ بِالأَمْرِ فَلْيَرْكَعْ رَكْعَتَيْنِ مِنْ غَيْرِ الْفَرِيضَةِ ثُمَّ لِيَقُلِ
If anyone of you is contemplating an affair, he should offer a two rak`at prayer other than the compulsory ones and say (after the prayer) [al-Bukhari]
Hafidh Ibn Hajar (may Allah have mercy upon him) said: “It is apparent [from the text] to delay the supplication from the prayer. If he supplicated during the prayer, then it is carried to be accepted. It is possible to carry the meaning of the order [mentioned in the Hadith] to mean preceding the beginning of the prayer before the supplication. For the place of supplication in the prayer is in the prostration or tashahhud. Ibn Abi Jamrah said, “the wisdom of preceding the prayer over the supplication is because the intent of the Istikharah is to obtain the gathering of the good of the worldly life and the hereafter. So it requires one to knock on the door of the King [Allah]. And there is nothing more effective nor more successful than prayer for the one who venerates Allah, extols Him, and shows dependence upon Him in the present and the future” End quote. [Fathul-Baari (11/186)]
Shaikh Ibn ul-‘Uthaymeen (may Allah have mercy upon him) said: “The supplication [of Istikharah] is after the salam as the statement of the Prophet indicates: “Then he prays two rak’aat, other than the obligatory prayers, then says…”. So this makes clear the order of the supplication being after the prayer. As for the supplication in other than Istikhaarah, then the origin for the one who wants to supplicate to Allah, the Exalted for something should supplicate for it in the prayer before the Salam” End quote. [Reference]
This is also the view of some of our contemporary Scholars like Shaikh Bin Baz [Reference], Shaikh al-Albani [Silsilatul-Huda wan-Nur no. 664], and Shaikh Muqbil (may Allah have mercy upon him) as Shaikh Yahya mentioned that from him in Kanzuth-Thameen (3/106), and it is also the Shaikh Yahya’s (may Allah preserve him) view as he mentions that in the following questions asked to him in Makkah
Listen / Download
[Reference from the 20:07 min mark until 20:56]
However, Shaikh Yahya (may Allah preserve him) said in the above audio that if a person does it before the salam, then it is not detested. And we know that is also the view of some of the Scholars like Shaikhul-Islaam Ibn Taymiyyah (may Allah have mercy upon him).
And Allah knows Best
Faisal bin Abdul Qaadir bin Hassan
Abu Sulaymaan