The priority is to keep yourself and others safe on the roads, whilst also ensuring no discomfort or pressure is put on the healing wounds. This is mostly dependant on:
The type of surgery and anaesthetic
If you have to travel for work
Any use of strong pain medications after surgery
Some examples are:
Following a gastroscopy with sedation, the limiting factor is any lag over effect of the anaesthetic for the medication to be reliably out of your system, so a period of 24 hours is usually sufficient to be safe on the road.
Following a keyhole gallbladder operation, it would likely be ok to drive after a week or so (when you shouldn’t need any further strong opiod pain relief and the wounds are mostly healed).
Following an open cancer operation, it may be closer to a month.
Your surgeon will give you the recommendation for your particular situation and this may change depending on how you feel after the procedure. You should test yourself sitting in the car first, then in a quiet safe location. You should also check in with your motor insurance company. Most importantly, keep yourself and those around you safe.