Malik's translation of the verse is:
O Prophet tell the Christians: "If the Compassionate (Allah) had a son, I would be the first to worship him."
Therefore it is directed to the Christians.
From Tafsir at-Tabari:
"If the Most Beneficent (Allah) had a son (or children as you pretend), then I am the first of Allah's worshippers [who deny and refute this claim of yours (and the first to believe in Allah Alone and testify that He has no children)]."
From Tafsir al-Maududi:
Say: "If the Merciful One had a son, I would have been the first one to worship him."
It means: My rejection of somebody’s being God’s offspring and my refusal to worship those whom you regard as His offspring is not due to any stubbornness and obduracy. My reason for the refusal is only this that God has no son or daughter, and your such beliefs are against the reality; otherwise I am such a faithful servant of my Lord that if at all the reality had been the same as you state I would have submitted myself in worship before you.
It is saying that Muhammad to say to the Christians that if Allah had a son (which you (Christians) pretend He does) then Muhammad will say to them that He is the first person to say that what they believe is false.
And Allah knows best.