Is there a way to use PWM to control AC mains powered heater?
Yes, you can do this.  However, anything called a "mains powered heater" has a time constant way longer than a power line cycle.  You can still modulate the power to the heating element (resistor), but it is much easier to do this in multiples of line cycles or at most half line cycles.

I actually did this in a real product once.  This product had to accurately control the temperature of a couple dozen line-driven heaters.  The controller got temperature measurements from thermistors, then controlled the heaters by switching each one on or off for a 1/2 power cycles.  This was done using solid state relays that only switched the outputs to a different state at each zero crossing of the AC line.  Doing this reduces transients from switching, and keeps the heater power linearly proportional to the PWM value.

Instead of straight PWM where the output is turned on for some fraction of a fixed period, then off for the rest, I used a Bresenham algorithm to switch each half line cycle separately.  The worst case low frequency content is still the same, but the average is better.

In this case, I had the control algorithm produce a byte representing the desired heater power.  Since each PWM time slice was 1/2 power line cycle, and the PWM period was 255 slices, this period was 2.13 seconds for 60 Hz power.  For 50 Hz power it would be 2.55 seconds.  As long as the heater's response is significantly slower than that, this works fine.  In my case, the first time constant was several minutes, so a few seconds was plenty fast enough for the PWM period.