I’m not sure that you can change this dynamically. Its a static switch that actually reduces or recalculates all instructions for the material. other material branches that can be adjusted at run time need to calculate both possible paths and then discard one or the other (keeps instruction # the same across all pixels). From the Documentation on Static switch:
This parameter is named static because it cannot change at runtime, it can only be set in the Material Instance Editor. Static Switches are applied at compile time, not at runtime. This means that whatever branch of the material was dropped will never be executed, so static switches are effectively free at runtime. On the other hand, a new version of the material must be compiled out for every used combination of static parameters in a material, which can lead to a shader explosion if abused. Try to minimize the number of static parameters in the material and the number of permutations of those static parameters that are actually used.
https://docs.unrealengine.com/en-US/RenderingAndGraphics/Materials/ExpressionReference/Parameters/index.html
You can always get around this potentially if its a major concern by swapping the material (instance) used in the post process at run time, that’s completely fine.