This is an objectionable act and there is no sound source for it. It is not allowed to do such a thing. What is legally sanctioned is to seek refuge from them by Allah’s complete words from every devil and poisonous pest, as has been confirmed from the Prophet (sallallaahu ‘alaihi-wasallam). He use to seek protection by those words for his grandsons al-Hasan and al-Husain ibn Ali. It is also sanctioned to make dua for them by asking Allah to protect them from every evil.
As for putting a knife or something similar, or iron, wood or other substances, with the belief that such will protect them from the jinn, it is an evil practice that is not allowed.
Similar is the ruling with respect to hanging an amulet over them, which is what is called al-tama’im. This is not allowed because the Prophet (sallallaahu ‘alaihi-wasallam) said,
“ Whoever hangs an amulet, Allah will not complete [his affair] for him. ” 
In another narration the Prophet (sallallaahu ‘alaihi-wasallam) said,
“ Whoever wears an amulet has committed Shirk .” 
May Allah bestow understanding of the religion upon all Muslims, and steadfastness in the religion. We seek refuge for ourselves and them from everything that differs from His pure law.
 Recorded by Ahmed, Ibn Hibban and others.
 Recorded by Ahmed, al al-Hakim.