It is not part of the Sunnah as the Prophet salla Allahu alaihi wa sallam didn’t recommend it for us. This is something related to the customs and culture of the people. When you are in a country where all of them cover their heads, it is recommended to do that in prayer and also when you are not praying. However if a person only wears it when he goes to prayer, as we see some Muslims putting their handkerchief on their heads just to cover their hair while praying, this becomes an innovation.