In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
1- The minimum number of Duha prayer is two rakahs.
2- There is no specific maximum number for Duha prayer.
3- Duha prayer is to be offered like other Sunnah prayers two rakahs by two.
Answering your question, the Fatwa Center at Islam Q and A, states:
Minimum Number of Rakahs
The minimum number of Duha prayer is two rakahs. Prophet Muhammad (peace be upon him) said: “…and two rakahs offered in the forenoon (Duha) will suffice for that.” (Muslim)
Abu Hurairah that he said: My close friend (peace be upon him) advised me to do three things: to fast three days of every month, to pray two rakahs of Duha, and to pray Witr before going to sleep.” (Al-Bukhari and Muslim)
Maximum Number of Rakahs
With regard to the maximum number, there is no text that defines that But it is proven that the Prophet prayed Duha with four rakahs, and with more than that, and with eight rakahs, as on the day of the conquest of Makkah.
Muadhah (may Allah have mercy on her) asked Aishah (may Allah be pleased with her): How many (rakahs) did the Messenger of Allah pray in Duha? She said: Four rakahs, and however many more he wanted. (Muslim)
Umm Hani’ (may Allah be pleased with her) said: The Messenger of Allah got up to do ghusl, and Fatimah screened him. Then he took his garment and wrapped it around himself, then he prayed eight rakahs of Duha prayer.
It says in Al-Mawsuah al-Fiqhiyyah (27/225):
“There is no difference of opinion among the jurists who say that Duha prayer is mustahabb with regard to the minimum number of rakahs being two. Abu Dharr narrated that the Prophet said: “…and two rakahs offered in the forenoon (Duha) will suffice for that.” So the minimum for Duha prayer is two rakahs, because of this report.
However, they differed concerning the maximum.
The Malikis and Hanbalis are of the view that the maximum for Duha prayer is eight rakahs. Umm Hani’ reported that the Prophet entered her house on the day of the conquests of Makkah and prayed eight rakahs. (She said:) and I never saw any prayer that was more brief than it, although he bowed and prostrated perfectly.
The Hanafis and Shafi`is – according to the more correct view – and Ahmad, according to a report narrated from him, are of the view that the maximum for Duha prayer is twelve rakahs. This is because of a report narrated by At-Tirmidhi and an-Nasai, with an isnad in which there is some weakness. According to this report, the Prophet said: “Whoever prays Duha with twelve rakahs, Allah will build for him a palace of gold in Paradise.”
The correct view is that there is no specific maximum number for Duha prayer. Rather a person may pray as many rakahs as he wants, so long as this prayer is done two rakahs by two.
Duha prayer is to be offered like other Sunnah prayers two rakahs by two.
Almighty Allah knows best.