Topping the golf ball is usually a beginner problem and can be very frustrating. I hear a lot of golfers say that they need to keep their head down and then they'll stop topping the golf ball. However, trying to keep your head down is not really the right solution to this problem.
When a golfer tops the golf ball, their club head is hitting only a top portion of the golf ball and not the whole ball. The idea is we want the club head to hit the whole ball, that's how it goes up in the air correctly.
Logically, if a golfer raises up with their body in the downswing or at impact, their clubhead will also be pulled up with them which will lead to topping the ball.
The root cause of "topping the golf ball" is the body coming up and it's usually the knees straightening. So, focus on keeping your knees flexed as your are hitting the golf ball. We don't really want to stand up until about halfway into the follow through well after the ball has been hit.
Trying to keep your head down can actually lead to lots of other problems. The body becomes rigid and you'll likely lose your sequence and smoothness of the swing that is necessary for good golf shots.
Another simple reason that a golfer can top the ball is from bending their arms when they are hitting the ball. You want to hit the ball with the arms straight and extended, just like they were in the setup position. So, maintain your angles from your setup position throughout the swing and at impact and you'll be on your way to eliminating any topped golf shots.
We want the swing path through impact to be more of a U and less like a V. If the clubhead comes up too quickly through impact, you're going to hit the top of the ball. Try to make a wider swing arc so the clubhead stays low to the ground longer through the impact area.
A simple drill that can work well is placing a small tee in the ground a couple of inches in front of your golf ball. Try and swing through the ball and clip the tee in front of the ball. This will give you the feeling of keeping your clubhead lower to the ground just after impact.