Praise be to Allah, and may peace and blessings be upon the Messenger of Allah.
The supplication in question is:
"O community of jinn, I adjure you by the covenant that Solomon, son of David, took from you, not to appear before us or harm us."
A hadith with a similar meaning was narrated from the Prophet ﷺ concerning snakes found in people's homes. However, this hadith is weak and unauthentic because its narrator, Muhammad ibn Abd al-Rahman ibn Abi Layla, was weak in hadith narration. Therefore, it is not permissible to attribute it to the Prophet ﷺ as an authentic hadith.
There are authentic remembrances reported in the Sunnah that are sufficient, including:
1. Supplication when stopping at a place
"I seek refuge in the perfect words of Allah from the evil of what He has created."
The Prophet ﷺ said:
"Whoever stops at a place and then says: 'I seek refuge in the perfect words of Allah from the evil of what He has created,' nothing will harm him until he departs from that place."
Narrated by Muslim.
2. Remembrance in the morning and evening
"In the name of Allah, with whose name nothing on earth or in heaven can cause harm, and He is the All-Hearing, the All-Knowing."
It should be recited three times in the morning and three times in the evening.
3. Reciting Surah Al-Ikhlas and the two protective chapters
A Muslim should recite Surah Al-Ikhlas, Surah Al-Falaq, and Surah An-Nas three times in the morning and evening.
4. Reciting Ayat Al-Kursi before sleeping
It is authentically reported in Sahih Al-Bukhari that whoever recites Ayat Al-Kursi before sleeping will have a guardian from Allah watching over him, and no devil will approach him until morning.
Conclusion:
The supplication attributed to the covenant of Prophet Solomon (peace be upon him) with the jinn has not been authentically established from the Prophet ﷺ, so it should not be relied upon. Instead, Muslims should regularly observe the authentic remembrances and supplications reported in the Sunnah, while placing their trust in Allah Almighty.
And Allah knows best.