Depends on many choices.
If you’re a serial frame swapper and expect the fork to find use on another bike or you’re using a less-well known headset that you may not be able to replace like-for-like then it’s sensible to include some extra spacers to maintain choice for later applications.
If you aren’t completely sure about your bike setup then likewise it’s a good idea to keep the steerer a bit longer and thus extra spacers – at least to begin with.
You need a small gap (around 5mm, a bit more won’t hurt) for proper setup of preload – the top cap has nothing to do with steerer clamping or holding the fork to the bike but everything to do with preloading the headset bearings (getting them to the right tension). If the top cap sits on top of the steerer it can’t do that, as it needs to be able to pull the steerer up a bit. Once the stem is clamped, the top cap is decoration only. This is where the design of the stem comes in – the stem clamps the steerer with the bolts to the rear of it – this is what holds your fork on your bike. You don’t want the top of the steerer to be below the uppermost bolt on the back of the stem – if it is then tightening the top bolt of the clamp is going to cause the stem to crimp as it’ll be unsupported. That is likely to reduce clamping force and in a best case be a creak that you can never quite track down and in a worst case could possibly lead to a stem failure and you crashing. This is really where the ‘small spacer on top’ comes from – it lets you cut the steerer to the top of the stem but still lets you have the adjustment needed for correct preload,
If you’re sure about setup, don’t plan to change headset brand, don’t plan to move the fork to another frame and have a stem that will let you have around 5mm between the clamping area of the top clamp bolt and the top of the stem where the top cap will sit so that you can cut your steerer appropriately then no spacers are actually needed. They’re partly for allowing tweaks to bike fit and partly to allow flexibility for component change.