Replacing HDD with SSD; what about non-APFS/APFS? iMac 27-inch, Late 2013, macOS up-to-date

I would like to back up my internal HDD (non-APFS) with Time Machine. Then erase the HDD. Then have the HDD replaced with a new internal SSD. Then restore from Time Machine.

Should I take precautions for the simultaneous switch from non-APFS to APFS? For example, must I convert the HDD to APFS before the steps mentioned above?
No, you don't need to convert the HDD. I recently did exactly what you're doing (though I installed the new SSD myself, which meant not having to worry about erasing the HDD) and didn't have to do any conversion.

But, just to be on the safe side, it would be smart to not only make sure you have a Time Machine backup but also clone your HDD to a different drive than the one that has your Time Machine backup. That way if, for whatever reason, you have a problem with restoring from the Time Machine backup, you have a fall-back plan. Better safe than sorry. You can clone the internal HDD to a second drive using Apple's Disk Utility or something like Carbon Copy Cloner. Instructions are readily available.

The other thing I'd suggest is that instead of simply restoring everything from your Time Machine backup to the new SSD you do a clean installation of macOS onto the new drive and then just restore your files and data using Migration Assistant. That way you get the benefits of a fresh OS installation along with the benefits of your new SSD.