No it isn't mandatory. It is a good sunna in most madhabs and abrogated according to some others because of the hadith:
Abu Salama b. Abd al-Rahman b. 'Auf heard Abu Huraira say:
(When) Allah's Messenger (ﷺ) (wished to invoke curse or blessing on
someone, he would do so at the end) of the recitation in the dawn
prayer, when he had pronounced Allah-o-Akbar (for bending) and then
lifted his head (saying):" Allah listened to him who praised Him; our
Lord! to Thee is all praise" ; he would then stand up and say:" Rescue
al-Walid b. Walid, Salama b. Hisham, and 'Ayyash b. Abd Rabi'a, and
the helpless among the Muslims. O Allah! trample severely Mudar and
cause them a famine (which broke out at the time) of Joseph. O Allah!
curse Lihyan, Ri'l, Dhakwan, 'Usayya, for they disobeyed Allah and His
Messenger."
(The narrator then adds): The news reached us that he abandoned
(this) when this verse was revealed:" Thou but no concern in the
matter whether He turns to them (mercifully) or chastises them; surely
they are wrongdoers" (Surat al-'Imran (3:128)]
[Sahih Muslim and partly in other Hadith books like Sahih al-Bukhari]
And well it was narrated to be done before or after the ruku'.
It was narrated that Anas bin Malik said: He was asked about Qunut in
the Subh prayer, and he said: “We used to recite Qunut before Ruku’
and afterwards.”
[Sunan ibn Majah]
Al-Bara bin Azib narrated: "The Prophet (S) would perform the Qunut in
the Subh and Maghrib prayers."
[Jami' at-Tirmidhi]
Some madhabs regard it to be a sunna in 2nd raka'a of the fajr/sobh fard prayer others in the witr prayer. At least one can do it in any Prayer if the situation require it.