I find this happens on new installations when I don't lock the upper race and its locknut together tightly enough. When older installations start to show play, I try to tighten it but often just proceed to rebuilding the headset. It could be caused by wear.
Consider a fork on a bike ridden over irregular pavement. The front wheel is bouncing up and down, flexing the fork blades, the fork crown, and as the fork crown is torqued by the blades it transmits that motion to the steer tube. As the lower bearing thus twists, the upper bearing is pulled and twisted. All this may tend to loosen a bearing that is not secured enough.