It is allowed. Most of the times goalkeepers will head butt the ball when outside of their penalty box and can no longer use their hands.
Bethany B.
asked 01/08/19Can a goalie head butt a soccer ball if he can’t react with his hands fast enough?
I have wondered about this for awhile. My soccer coach said that if you can you could head butt it out of the Goal but you don’t have to.
2 Answers By Expert Tutors

Nicholas S. answered 03/14/19
Experienced High School Boy's Varsity Head Soccer Coach
Yes this is allowed, however it is not seen very often as it can be quite dangerous. Usually the only time a keeper will head butt the ball is when they are outside of their penalty box and can no longer use their hands.
Hope this was helpful!
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.