The P0147 code indicates that there is a problem with the oxygen sensor heater circuit for the post-catalyst oxygen sensor. This sensor is there to monitor operation of the catalytic converter for emissions reasons, and will not affect how the engine runs. So, the p0147 code is most likely not related to your surging problem.
There are many things that can cause a vehicle to surge while driving; some degree of testing is going to need to be done to locate the exact cause in your case.
A misfiring cylinder can cause such a sensation; if you ahve not replaced the spark plugs, cap, rotor, and wires for a few years you might want to start there. These are tune-up parts that need to be replaced periodically for maintenance anyway.
A clogged fuel filter can cause an engine to surge, as can low fuel pressure froma failing fuel pump.
If the EGR valve is stuck open it can cause a surge and/ or a rough idle.
A failing torque converter clutch can cause a noticeable surging at highway speeds as it locks in and out. Try touching the brake pedal to make the brake lights come on while the problem is occurring; if this makes it stop immediately then you are dealing with a torque converter issue.
Fuel injector problems on this design are also common.