Head gasket issues are a nightmare and can be extremely expensive to fix. Sometimes they are so bad that it is simply not worth repairing the vehicle.
You may not even have any warning as to when your head gasket is on its way out but when it goes it can cause so much damage that the car will become un-driveable and will require a new engine to fix it.
You could try and save a bit of money and buy a reconditioned engine to fit in it but you will have to make sure that you buy one with some sort of warranty as you could find yourself in the same position a few weeks or months down the line. Also there is quite a big labour cost involved in fitting a new engine so you will have to factor this in.
The labour costs of fitting a new engine can be more than the cost of the engine itself and therefore you have to weigh up if the vehicle is worth repairing. If it is an older second hand vehicle then it may be better to get scrap value for it and although this is only usually £100-£200 it may save you having to fork out more money on it and cut your losses.