You have an intermittent problem which makes the diagnosis to a particular part even more difficult. Sometimes other problems (like O2 sensors, EGR, improper coolant temperature, vacuum leaks etc.) can trigger this code, as the way it is detected is during the drive cycle the secondary air pump is turned on , air is injected into the exhaust side and the O2 sensor(s) are monitored for a very lean condition (due to injected oxygen in the air) in two consecutive drive cycles. Thus, you need to make sure there are no other conditions that would interfere with the test results (increase of lambda from the O2 sensors by 23 percent or more)
Once the problem is isolated to the secondary air injection system, then the operation of the air pump, switchover valve and the combination valves (one per bank) can be checked. The common problems are sticking switchover valve, leaky check valves (of the combi valve), air and vacuum supply hoses between components (kinks, holes , splits, loose connections), intermittent electrical contacts, and the intermittent operation of the air pump (which requires something like 35 amps, and possible to have worn brushes), and the air pump relay itself (worn contacts over time). The air pump turns on when the engine is cold for few minutes, so you can "simulate" the cold engine condition to check the air pump and the equipment down the chain.