There should be a factory reset option in the system menu. That will erase user apps, settings and data (not normally SD card data).
If you want to do more than that I guess you need to reflash the phone with a new set of software. For that you'll need to post again to tell us what phone you have, because it's different between different models.