I have a gas fireplace that the on/off function is controlled by a light switch. The switch is connected to two wires only, a black and white wire. There is no ground wire. Can a smart switch be used as a replacement and will it work?
Probably not. On the gas fireplaces I have installed the on off switch was a millivolt contact. If this is the case there will be no power to run the smart switch unless it is battery powered. If the fireplace is a 120v control then in most cases you will need a neutral. If you provide the model of the fireplace and the smart switch we could provide more information. There are some smart switches that do not require neutrals but depending on the type of control for the fireplace even those might not work.
You have hot and switched hot. The smart switch needs to get power from somewhere. Some do this by letting a little current through even when the switch is off. If that's the case I would absolutely not recommend it for anything except lighting and especially not for a gas ignition.
On the other hand, it may get power by connecting to neutral. Historically, neutral has not been needed for switches. Current code requires neutral in switch boxes for exactly this reason. If neutral is accessible then you're set. If not then this won't work without a new cable that includes neutral.
Very important: Make sure the switch does not have a dimming feature. Dimmers should only be used with dimmer compatible lighting and not with motors or anything like a gas fireplace that will only work properly with On/Off.