Foreman is correct; it is a finial for a flagpole. The proper name for a flag finial is a 'truck.' The spear was used on the early battle flags and banners because the color bearer was expected to fight and use the flagpole like a weapon.
Most 'yard/outdoor' flagpoles generally have a 'ball' on top to prevent rain water from getting inside the pole, and it helps to prevent the flag from getting tangled with the rope or top of the pole.