This has been previously touched on here: “Commentor” vs “Commentator”“Commentor” vs “Commentator”. I'll try to expand on that.
Both -er and -or are so-called "agent noun suffixes", and Wiktionary has entries for both:
Generally speaking, -er is much more common in English (which should come as no surprise since it has deep Germanic roots, see the link) and can be easily attached to any English verb to form the corresponding noun (drive — driver, run — runner, drink — drinker, etc.).
The suffix -or, on the other hand, comes from Latin, and is used much more seldom, basically where Latin would do it. Just try building the words drivor, runnor or drinkor, and see for yourself. In fact, Wiktionary lists only a handful of terms that were derived using this suffix, such as actor, author and sculptor, and goes on to provide the following usage notes:
English generally appends this suffix where Latin would do it—to the root of a Latin-type perfect passive participle. For other words, English tends to use the suffix -er. Occasionally both are used (computer vs. computor).
Etymonline has additional info on the origin and usage of -er and -or.
Edit: courtesy of Martha, here's a link to a post on the "Separated by a common language" blog that provides further details and addresses the differences between US and UK English:
The -or suffix is primarily found in words derived from Latin, whereas -er can be put on the end of just about any verb that involves an agent (a 'doer' of the 'action'). But Latin-derived words differ in how strongly they are associated with the -or suffix. Latin-derived verbs that end in -ate, for example, almost always take the -or suffix. So we have dictator, but not a variant dictater, alternator but not alternater.
Things are less clear-cut with other Latin-derived verbs. For example, in my job, I advise students and convene courses, and when I spell out those roles, I'm an advisor and a convenor, but when my UK university spells them, I'm often an adviser (which just looks wrong to me) and a convener. [...] The -or form is stronger in the US than the UK, though there's considerable variation within each country.