If your computer has been hacked or infected, is there a way of cleaning your computer and have 100% sure that it's clean?
Technically it is impossible short of verifying every circuit path, bit of storage/memory and piece of data on your computer.
You have to practically start your trust some where. Computers are incredibly complex devices and there are simply too many possible attack vectors.
For the majority of attacks, formatting the hard drives and doing a clean install is sufficient, however there are demonstrated attacks that can compromise systems permanently or infect software you build yourself through hardware or compiler level exploits.
If you expect you are targeted, you're best bet is to source hardware from someplace you trust and be very careful what you install. If you just want to be safe from general threats, avoid questionable content, patch your system regularly and keep virus scanner up to date to minimize risk of an infection after you rebuild.
I haven't heard about mainstream malware, that infects firmware in any way.
So if we assume there's no attack on you personally, it should be enough to wipe the harddisk and install an OS from a source you can trust. The same for the software and drivers you will install.
If the attack is personally on you, there are many ways like firmware hiding the boot sector to the os which will run a rootkit, rf senders hidden on your board, uefi rootkit... the list is long.