All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger.
Swearing by the Prophet, sallallaahu ‘alayhi wa sallam, is forbidden and if one takes an oath by the Prophet, sallallaahu ‘alayhi wa sallam, it is not considered a binding oath and no expiation is due in such a case. This is the opinion of the majority of Muslim scholars: Imaam Maalik, Abu Haneefah, Ash-Shaafi‘i, and Ahmad according to one of his two opinions. This is the preponderant of his two opinions in this regard. The other opinion suggests that swearing by the Prophet, sallallaahu ‘alayhi wa sallam, is considered a binding oath, apart from anyone or anything else other than Allaah The Exalted. The majority of scholars cited evidence from the following Hadeeths: It was reported on the authority of Ibn ‘Umar that the Prophet, sallallaahu ‘alayhi wa sallam, said: "Whoever has to take an oath should swear by Allaah The Exalted or remain silent (i.e. He should not swear by other than Allaah.)." Another Hadeeth in this regard reads, "He who has to take an oath must not take an oath except by Allaah The Exalted." [Muslim] Another Hadeeth was reported by At-Tirmithi and Abu Daawood and it reads, "Whoever swears by other than Allaah The Exalted has committed an act of Kufr (disbelief) or Shirk (association of partners with Allaah The Almighty in worship)." [At-Tirmithi and Abu Daawood]
Shaykh Al-Islaam Ibn Taymiyyah said, "Stating that it is obligatory for someone to make an expiation for breaking an oath which he has sworn by a created being – even if it was a prophet – is extremely weak and goes against religious texts and pieces of evidence."
Ibn Qudaamah said, "An oath is not considered binding if the person swears by a created being or something such as the Ka‘bah, prophets, or any other creature. An expiation is not obligatory on the oath-taker if he breaks the oath. This is the apparent meaning of the opinion of Imaam Al-Khiraqi . It is also the opinion of most of the Muslim jurists . The Hanbali scholars, however, believed that swearing by the Prophet, sallallaahu ‘alayhi wa sallam, is considered a binding oath, and that breaking it entails expiation.
Therefore, if a person falsely swears by the Prophet, sallallaahu ‘alayhi wa sallam, he should repent to Allaah The Exalted. Expiation is due when a binding oath is broken. The person who gave Fatwa that expiation is obligatory in such a case may be a follower of the opinion of the Hanbali school of Fiqh, which is explained in the aforementioned words of Ibn Qudaamah .
Allaah Knows best.