I am using this circuit with a BTA16 TRIAC:
The load is a 110/12 V transformer. I am getting spikes in the output.
Note: CH1 is the secondary of the transformer (load), CH2 is the MOC3021 input.
How can I get rid of the spikes?
Your TRIAC does turn off correctly. Remember, it's turning off automatically as soon the current through it is zero. Not as soon the voltage over it is zero.
What you have there is a slightly inductive load which introduces a phase-shift between voltage and current. It's all okay. Those spikes will become a bit smaller as soon you put more load on the 12V side of the transformer, but in general, they do no harm. They only affect your minimal control angle.