You can remove the SIM card before or after erasing all content and settings, it makes no difference. The new owner will, however, have to insert a SIM card before activating the iPhone.
You can pull out SIM card, it doesn't influence iPhone resetting. When you finish reset, you should insert SIM card, because you need it to activate iPhone.