Do I need to shut the gas off to my fireplace before replacing the wall switch?
Generally speaking it's not necessary.
Disconnecting the switch is no different than turning the switch off. Both can create tiny sparks and both leave the fireplace without power. Of course, if you turn off the breaker as you should, sparks are less likely.
Either you have an electronic gas valve, in which case it'll remain closed, or you have a pilot flame, in which case it'll continue burning. Both are safe conditions.