I have an unlocked G1 that is freaking out on me in various ways. If I "restore factory settings" am I going to wind up locking it?
Normally unlocked phones are unlocked for good. I wouldn't expect a factory reset to change it. (See also: Unlocked Galaxy i7500, Reset Will Remove it?)
It's not 100% certain, though. For example, some Galaxy S users had their phones re-locked when updating from 2.1 to 2.2, which is a somewhat similar process to doing a factory reset.
You could always do a backup through ClockworkMod or something (and back it up to your computer first) in case it does get re-locked, so that you could restore it to the previous unlocked state. That requires root, however. (Root can sometimes be undone by a factory reset, but not if you have a custom ROM that came pre-rooted).
If you have the unlock code from when you originally unlocked it, that code should still work to unlock it again if it gets re-locked.
I have an HTC Sensation 4G that originally was purchased from T-mobile. I unlocked it using the code provided by T-mobile (free) and used it on AT&T. I just did a factory settings reset as instructed in the user manual and it still works fine and is still unlocked.