
When the name "Muhammad" (محمد) is mentioned in a gathering and the intended reference is the Prophet ﷺ himself, it is wajib [obligatory] to recite Darud Sharif once, and mustahab [recommended] to recite it more than once.
However, if someone has been given the name Muhammad, or Muhammad forms part of their name, and the reference at the time of mention is that person, then it is not correct to recite or write Darud Sharif when calling them or writing their name. This is because reciting Darud Sharif is permitted for the Prophet ﷺ and the other Prophets (علیہم الصلاۃ والسلام); it is not permissible to recite it independently for anyone else.
Allah the Almighty knows best.
Darul Ifta Al-Ikhlas, Karachi.
روح المعانی: (260/11، ط: دار الکتب العلمیۃ)
وبه يرد على الخفاجي قوله في شرح الشفاء صلاة الملائكة على الأمة لا تكون إلا بتبعيته صلى الله عليه وسلم. وقيل لا تجوز مطلقا. وقيل لا تجوز استقلالا وتجوز تبعا فيما ورد فيه النص كالآل أو ألحق به كالأصحاب. واختاره القرطبي وغيره وقيل تجوز تبعا مطلقا ولا تجوز استقلالا ونسب إلى أبي حنيفة وجمع. وفي تنوير الأبصار ولا يصلي على غير الأنبياء والملائكة إلا بطريق التبع وهو محتمل لكراهة الصلاة بدون تبع تحريما ولكراهتها تنزيها ولكونها خلاف الأولى لكن ذكر البيري من الحنفية من صلى على غيرهم إثم وكره وهو الصحيح.