Yes, it does in most cases. Factory reset does format your entire system which also removes the malware that had affected the device, although the same cannot be said about network worms which affect the whole network. Similar is the case for cloud storages. For eg., malicious adds-ons in Chrome or Firefox might return if data is re-synced.