Andy, you'll have loose ball bearings(unlikely), bearings in a cage as pictured or sealed cartridges which are just a variation on the former but in their own little tin. You have one set above and one below and they will be sandwiched between two parts. The cup that presses into the frame, or the frame itself if integrated and the upper/lower races. Bascially think of them coming together to form a hollow metal donut that has greased ball bearings inside.
It's simply a case of taking it all apart, making sure to keep everything in the right order, then cleaning and re-greasing and reassembling. The cleaning bit will also allow you to inspect and see if the surfaces are worn/pitted or if the ball bearings themselves are degraded. Really bad would be if they are turning to rusty mush. But all of the bits are replaceable and often pretty cheaply if via a local bike shop.
When putting it back together you 'pre-load' the bearings via the stem bolt before tightening the stem itself...assuming it is an aheadset. This just means that you're pulling it all together tight enough to remove play. Too tight would scrunch the bearings up and cause faster wear, or more serious damage. It's a feel thing but quite an easy one, I can do it so it must be. I follow the old apply front brake and rock back to and fro. If the whole assembly is solid and the forks turn freely, then it's good. I normally start from a point I know it's not tight enough and do it up a small amount each time, re-testing in between.