When performing a factory reset on your Nintendo Switch, you generally don't need to remove the microSD card. However, it is a good practice to back up any important data or save files that may be on the microSD card, as a factory reset will erase all user data from the console.
If you're concerned about any potential data loss or corruption, you can safely remove the microSD card before the reset and later insert it back into the console after