Adding a spacer block between king stud and switch box
That's common practice. As long as the framing member is rigidly attached it doesn't really matter what other function it serves or what it's called. (Jester stud?)