To 'stave off' means to keep at bay, fight off, or defend against. In its original noun form, around 1400, the Oxford English Dictionary says, a “stave” was a thin strip of wood that was curved to make a cask or barrel. Staves was originally the plural of staff, a long rod or walking stick. So by extension, many kinds of sticks or rods, including the staffs of a lance or other weapon, were known as staves.
By the 1600s, stave evolved to mean drive off or beat with a staff or stave. The use was meant literally, as in to stave off an attack on the castle, possibly using lances or other weapons with staves. The common use today has become figurative, as in to stave off a cold.