The whip is a parliamentary term dating back to 1742. The term originates from the political party needing to "whip" MPs to get them to attend and vote according to the party line in the chamber, with the term originating from fox hunting.
It was originally used metaphorically to mean ensuring that the MPs for the party get to the chamber in order to vote, but it has since been expanded to mean the control in general exerted by a party over its MPs.
All other uses of whip derive from this original usage. In modern usage, whips are parliamentary enforcers who provide inducements and punishments to MPs who do not "toe the party line", and in the extreme case of expelling an MP from a party, the party withdraws the whip. This does not expel the MP from Parliament (since they are elected), but it means they can no longer represent the party officially, and will not be able to stand as the member of parliament for that party at the next general election.
In the UK we also have the following:
A single-line whip states the party's official policy and states when the vote is expected to take place, but there is no implied incentive or punishment for MPs to attend or vote with the party on this issue.
A two-line whip (or double-line whip), is an instruction by the party that the MP must attend and vote according to the party's "line".
A three-line whip is an order to attend and vote, with serious consequences threatened if the MP votes against the party or fails to attend the vote. Consequences can include expulsion from the party or loss of office.
In the UK, the team of whips are called the Whips' office, and the most senior whip who oversees the whips for that party is called the Chief Whip.
The Chief Whip for the incumbent party is normally appointed as Parliamentary Secretary to the Treasury, which affords him or her a place in Cabinet, and a house at 12 Downing Street. The Chief Whip for both parties reports directly to the party leader, which for the party in power is the Prime Minister.