Our solid propellant rocket, on test, produces sonic boom. Right after, the plume of exhaust tilts sideways. This will definitely have a gimbal effect during flight. The propellant chamber has one hole in the center to increase the burn surface area. I am assuming that the shock produced that shakes the propellant chamber crumbles the unburnt fuel inside. This affects the fuel burn and mass flow resulting in the tilting of the plume at the nozzle.
What is the condition of the nozzle after burnout? is it asymmetrically eroded? That points to nozzle failure.
If it is spitting chunky sparks, then your fuel grain is fracturing and you are operating not a rocket motor but a malfunctioning bomb. It is absolutely vital that your fuel grain remain mechanically intact and adhered to the sidewalls of the motor during firing, or really bad things can happen. Is your motor sidewall possibly not rigid enough?