In modern informal usage
Traditionally, who and whom are distinguished: who is used as a subject, whom as an object. But the distinction produces a number of inconsistencies, and it has confused even such native speakers as William Shakespeare, the translators of the King James Bible, and Daniel Defoe.1
Fortunately for the English learner, in modern informal English, you don't need to distinguish them. Who (as well as derived forms like whoever) can be used in all positions.
For instance, who can be used as both a subject and an object (as an interrogative):
Whosubject of "[i]s"'s there?
They sacked whoobject of "sacked"?
Whoobject of "to" will the task be assigned to?
and similarly when it heads a relative clause:
Give it to anyone who asks for it.
Give it to the employee who it's assigned to.
"Whom" will generally still be used when it immediately follows the preposition it is the object of. But such constructions are uncommon in informal English, since pied-piping of prepositions is used only in formal registers.
"Whomever" is essentially unused, with "whoever" used even immediately after a preposition:
Give it to whoeverobject of "to", subject of "asks" asks for it.
Give it to whoeverobject of "to", object of "picks" the computer picks.
1 That is, the distinction was never widely observed in detail.