It seems to be myth circulating among some people, but does not have any basis in Islamic teachings. The following are some references that came up in a cursory search:
The following fatwa from "The Standing Committee for Scholarly Research and Issuing Fatwas" - it labels the practice of using iron as a protection from Jinn as shirk:
تعليق الحديد ونحوه على المرأة النفساء والمختون لجلب النفع أو دفع الضرر
س: إذا ولدت المرأة تأخذ معها حديدا لمدة ٤٠ يوما ويعتقدون بهذا الحديد
أنه يمنع عنهم شر الجن ويعتقدون أن الحديد ينفعهم من دون الله فهو الذي
خلقهم أول مرة ولقد وصلنا إلى جدال أنا وأمي وزوجتي فما نصيحتكم لأمي
وزوجتي؟ عسى أن تكون نصيحتكم بركة تحل هذه المشكلة التي حدثت في كل
القبائل في ظفار، وأرجو نصيحة المسلمات اللاتي يعتقدن أن الحديد ينفع
ويضر من دون الله، وأرجو نصيحة مهمة في الموضوع نفسه حتى أستطيع أن أدعو
الناس إلى الطريق الصحيح، وكذلك الولد المختون يمكث نفس المدة التي
تمكثها المرأة لا يصوم ولا يصلي ويأخذ الحديد معه لمدة ٤٠ يوما، وأريد
نصيحة ودليلا بأسرع وقت ممكن جزاكم الله خير الجزاء عن الإسلام
والمسلمين.
ج: من أنواع الشرك الأكبر المخرج من دين الإسلام؛ تعليق الحديد ونحوه على
المرأة النفساء والمختون لجلب النفع أو دفع الضرر، قال تعالى: {وإن يمسسك
الله بضر فلا كاشف له إلا هو وإن يردك بخير فلا راد لفضله يصيب به من
يشاء من عباده وهو الغفور الرحيم} (١) وعن عمران بن حصين رضي الله عنه،
«أن النبي صلى الله عليه وسلم رأى رجلا في يده حلقة من صفر فقال: ما هذه؟
قال: من الواهنة: فقال: انزعها فإنها لا تزيدك إلا وهنا، فإنك لو مت وهي
عليك ما أفلحت أبدا (٢) » وعن عقبة بن عامر رضي الله عنه مرفوعا: «من
تعلق تميمة فلا أتم الله له، ومن تعلق ودعة فلا ودع الله له (٣) » رواهما
أحمد وفي رواية: «من تعلق تميمة فقد أشرك (١) » وقد أحسنت في نصيحتك لمن
ذكر وعنايتك بإرشادهما إلى ترك هذه البدعة الشركية جزاك الله خيرا.وبالله
التوفيق. وصلى الله على نبينا محمد، وآله وصحبه وسلم.اللجنة الدائمة
للبحوث العلمية والإفتاءعضو ... نائب رئيس اللجنة ... الرئيسعبد الله بن
غديان ... عبد الرزاق عفيفي ... عبد العزيز بن عبد الله بن باز
Hanging a piece of metal as a charm to bring about benefit or prevent
evil
Fatwa no. 10536
Q: When a woman gives birth to a baby, she would hang a metal rod for
forty days thinking that this piece of metal will protect her from
Jinn (creatures created from fire). Women believe that this metal will
benefit them rather than Allah Who has created them. I had a debate
with my mother and wife about this. What is your advice to my mother
and wife? I hope that your advice will solve this common problem among
the tribes of Zefar. Thus, please advise the Muslim women who think
that this piece of metal can bring benefit or cause harm. Advise me in
this regard in detail please, so I can invite people to adhere to the
right path. Likewise, a circumcised boy stays for forty days without
Sawm (Fast) or Salah (Prayer) wearing that piece of metal. I need
advice based on religious evidence as soon as possible. May Allah
reward you with the best for the efforts you exert for Islam and
Muslims.
A: Among the kinds of Al-Shirk-ul-Akbar (major form of associating
others in worship with Allah) that takes a person out of the fold of
Islam is the act of hanging a piece of metal by a woman during the
postpartum period or by a circumcised person as a charm to bring
benefit or prevent evil. Allah (Exalted be He) says: And if Allâh
touches you with harm, there is none who can remove it but He, and if
He intends any good for you, there is none who can repel His Favour
which He causes it to reach whomsoever of His slaves He wills. And He
is the Oft-Forgiving, the Most Merciful.
Imran ibn Al-Husayn (may Allah be pleased with him) narrated: The
Prophet (peace be upon him) saw a man with a gold amulet in his hand.
He then asked: What is that? He replied: A protection from weakness.
The Prophet (peace be upon him) said: 'Cast it off, for verily, it
would only increase your weakness and if you die wearing it, you will
never succeed.' Also Uqbah ibn Amir (may Allah be pleased with him)
narrated that the Prophet (peace be upon him) said in a Hadith Marfu`
(a Hadith narrated from the Prophet with a connected or disconnected
chain of narration): "Whoever wears an amulet to prosper, may Allah
prevent his prosperity and whoever wears a mascot for good luck, may
Allah debar his luck.'' (Both the two previous Hadiths are related by
Ahmad). In another narration: Whoever wears an amulet commits an act
of Shirk (associating others in worship with Allah.
Indeed, you have done well in advising your people and caring about
guiding them to abandon this Bid`ah Shirkiyyah (rejected innovation in
religion which is tantamount to associating others in worship with
Allah); May Allah reward you with the best.
May Allah grant us success. May peace and blessings of Allah be upon
our Prophet Muhammad, his family and Companions!
The Permanent Committee for Scholarly Research and Ifta'
Abdullah ibn Ghudayyan , Abdul-Razzaq Afify , Abdul-Aziz ibn Abdullah ibn Baz
— Fataawa al-Lajnah ad-Daa’imah - (Translation from alifta.gov.sa)
The following Urdu fatwa also mentions a similar practice, the author of the fatwa claims that it has no Islamic basis:
سوال:بعض لوگ اپنے بچوں کو جنوں وغیرہ سے بچانے کے لیے ان کے پاس چھری یا
لوہے کی کوئی چیز رکھ دیتے ہیں کیا ایسا کرنا درست ہے؟
جواب:یہ عمل درست نہیں اور شرعی طور پر اس کی کوئی صحیح بنیاد موجود
نہیں،شرعی طریقہ یہ ہے کہ بچوں کو شیطان کے شر سے بچانے کے لیے دم کیا
جائے جس طرح رسول اللہ صلی اللہ علیہ وسلم حسن اور حسین رضی اللہ عنہما
کو دم کیا کرتے تھے،صحیح البخاری میں ہے کہ رسول اللہ صلی اللہ علیہ وسلم
دم کے لیے یہ کلمات کہتے"أعوذ بكلمات اللّٰه التامة من كل شيطان وهامة
ومن كل عين لامة"میں ہر شیطان،ہر زہریلے کیڑے اور ہر نظربد سے اللہ کے
تمام کلمات کے ساتھ پناہ چاہتا ہوں۔یا بچوں کی حفاظت کے لیے اللہ تعالیٰ
سے دعا کرے۔بچوں کے پاس چھری،چاقو یا لوہا وغیرہ کی کوئی چیز اس اعتقاد
سے رکھنا کہ یہ انہیں شیطانی چالوں سے محفوظ رکھے گی تو یہ ناجائز
ہے۔اللہ تعالیٰ صحیح عمل کی توفیق بخشے۔آمین
Q: Some people place knives or other metal objects near their children to protect them from Jinn. Is doing that correct?
Ans: This action is not correct and has no authentic basis in shariah. The prescribed method in shariah is by using Ruqya as was done by the Messenger of Allah ﷺ for Hassan and Hussain. It is recorded in Sahih Bukhari that he used to perform ruqya for them using the words: أعوذ بكلمات الله التامة من كل شيطان وهامة، ومن كل عين لامة (O Allah! I seek Refuge with Your Perfect Words from every devil and from poisonous pests and from every evil, harmful, envious eye.)
Placing a knife, dagger or other iron object near children with the belief that it will protect from the devils is not permissible.
— تفہیم دین
the jinn are vulnerable to and/or afraid of iron
Did you read the footnote 61, the Wikipedia page? It is referencing "Gods, Spirits, and Worship in the Greco-Roman World and Early Christianity. (2022). Vereinigtes Königreich: Bloomsbury Publishing. p. 227" This is not from Islamic sources. Did you notice?