We have all seen it before and the usual cause ( about 90%) is a blocked carburettor
After that is debris in the fuel tank cutting off the fuel supply
next is air leak between carb & engine
Then comes faulty solenoid.
Then comes blocked fuel filter
Then blown head gasket / crankcase pressure leak
Then failed fuel line
Then faulty fuel pump
Not hard & fast order but on average they go like this
But in any case you diagnose the problem and apply one fix at a time
I usually start by flooding the manifold region with WD 40 from a trigger sprayer and see if the engine changes speed or blows smoke
I work the governor arm while doing this because on the overrun you get more suction so manifold leaks become more apparent ( white smoke )
Next I pull the fuel solenoid off & replace it with a bolt
While both these are less likely to be the problem they are quicker & easier to rule out first than pulling the carb off & cleaning it .
Being a tech, time is money and fixing a surging engine is basically a fixed 1.5 hour charge + parts out regardless of what the cause of the problem actually was .