The key is to reconstruct the inning if the error(s) didn't happen. It's pretty much as simple as that.
The entire rule from OBR is included below, more than you ever wanted to know but we love to quote the actual rule whenever we can. I appologize for not taking the time to reformat...
10.16 EARNED RUNS AND RUNS ALLOWED
An earned run is a run for which a pitcher is held accountable. In determining
earned runs, the official scorer shall reconstruct the inning without the errors (which exclude
catcher’s interference) and passed balls, giving the benefit of the doubt always to the pitcher
in determining which bases would have been reached by runners had there been errorless
play. For the purpose of determining earned runs, an intentional base on balls, regardless of
the circumstances, shall be construed in exactly the same manner as any other base on balls.
(a) The official scorer shall charge an earned run against a pitcher every time a runner
reaches home base by the aid of safe hits, sacrifice bunts, a sacrifice fly, stolen
bases, putouts, fielder’s choices, bases on balls, hit batters, balks or wild pitches
(including a wild pitch on third strike that permits a batter to reach first base) before
fielding chances have been offered to put out the offensive team. For the purpose of
this rule, a defensive interference penalty shall be construed as a fielding chance. A
wild pitch is solely the pitcher’s fault and shall contribute to an earned run just as a
base on balls or a balk.
Rule 10.16(a) Comment: The following are examples of earned runs charged to a pitcher:
(1) Peter pitches and retires Abel and Baker, the first two batters of an inning. Charlie reaches
first base on an error charged to a fielder. Daniel hits a home run. Edward hits a home run.
Peter retires Frank to end the inning. Three runs have scored, but no earned runs are charged
to Peter, because Charlie should have been the third out of the inning, as reconstructed
without the error.
(2) Peter pitches and retires Abel. Baker hits a triple. While pitching to Charlie, Peter throws a
wild pitch, allowing Baker to score. Peter retires Daniel and Edward. One run has scored,
charged as an earned run to Peter, because the wild pitch contributes to an earned run.
In an inning in which a batter-runner reaches first base on a catcher’s interference, such batterrunner
shall not count as an earned run should he subsequently score. The official scorer shall not
assume, however, that such batter would have made an out absent the catcher’s interference (unlike, for
Rule 10.16
113
example, situations in which a batter-runner reaches first base safely because of a fielder’s misplay of a
ball for an error). Because such batter never had a chance to complete his time at bat, it is unknown how
such batter would have fared absent the catcher’s interference. Compare the following examples:
(3) With two out, Abel reaches first on an error by the shortstop in misplaying a ground ball.
Baker hits a home run. Charlie strikes out. Two runs have scored, but none is earned,
because Abel’s at-bat should have been the third out of the inning, as reconstructed without
the error.
(4) With two out, Abel reaches first on a catcher’s interference. Baker hits a home run. Charlie
strikes out. Two runs have scored, but one (Baker’s) is earned, because the official scorer
cannot assume that Abel would have made an out to end the inning, absent the catcher’s
interference.
(b) No run shall be earned when scored by a runner who reaches first base
(1) on a hit or otherwise after his time at bat is prolonged by a muffed foul fly;
(2) because of interference or obstruction; or
(3) because of any fielding error.
(c) No run shall be earned when scored by a runner whose presence on the bases is
prolonged by an error, if such runner would have been put out by errorless play.
(d) No run shall be earned when the scoring runner’s advance has been aided by an
error, a passed ball or defensive interference or obstruction, if in the official scorer’s
judgment the run would not have scored without the aid of such misplay.
(e) An error by a pitcher is treated exactly the same as an error by any other fielder in
computing earned runs.
(f) Whenever a fielding error occurs, the pitcher shall be given the benefit of the doubt
in determining to which bases any runners would have advanced had the fielding of
the defensive team been errorless.
(g) When pitchers are changed during an inning, the official scorer shall not charge the
relief pitcher with any run (earned or unearned) scored by a runner who was on base
at the time such relief pitcher entered the game, nor for runs scored by any runner
who reaches base on a fielder’s choice that puts out a runner left on base by any
preceding pitcher.
Rule 10.16
114
Rule 10.16(g) Comment: It is the intent of Rule 10.16(g) to charge each pitcher with the number of
runners he put on base, rather than with the individual runners. When a pitcher puts runners on base and
is relieved, such pitcher shall be charged with all runs subsequently scored up to and including the
number of runners such pitcher left on base when such pitcher left the game, unless such runners are put
out without action by the batter (i.e., caught stealing, picked off base or called out for interference when a
batter-runner does not reach first base on the play). For example:
(1) Peter is pitching. Abel reaches first base on a base on balls. Roger relieves Peter. Baker
grounds out, advancing Abel to second base. Charlie flies out. Daniel singles, scoring Abel.
Abel’s run is charged to Peter
(2) Peter is pitching. Abel reaches first base on a base on balls. Roger relieves Peter. Baker
forces Abel at second bases. Charlie grounds out, advancing Baker to second base. Daniel
singles, scoring Baker. Baker’s run is charged to Peter.
(3) Peter is pitching. Abel reaches first base on a base on balls. Roger relieves Peter. Baker
singles, advancing Abel to third base. Charlie grounds to short, with Abel out at home plate
and Baker advancing to second base. Daniel flies out. Edward singles, scoring Baker.
Baker’s run is charged to Peter.
(4) Peter is pitching. Abel reaches first base on a base on balls. Roger relieves Peter. Baker
reaches on a base on balls. Charlie flies out. Abel is picked off second base. Daniel
doubles, scoring Baker from first base. Baker’s run is charged to Roger.
(5) Peter is pitching. Abel reaches first base on a base on balls. Roger relieves Peter. Baker
reaches first base on a base on balls. Sierra relieves Roger. Charlie forces Abel at third base.
Daniel forces Baker at third base. Edward hits a home run, scoring three runs. The official
scorer shall charge one run to Peter, one run to Roger and one run to Sierra.
(6) Peter is pitching. Abel reaches first base on a base on balls. Roger relieves Peter. Baker
reaches first base on a base on balls. Charlie singles, filling the bases. Daniel forces Abel at
home plate. Edward singles, scoring Baker and Charlie. The official scorer shall charge one
run to Peter and one run to Roger.
(7) Peter is pitching. Abel reaches first base on a base on balls. Roger relieves Peter. Baker
singles, but Abel is out trying to reach third base and Baker advances to second base on the
throw. Charlie singles, scoring Baker. Baker’s run is charged to Roger.
(h) A relief pitcher shall not be held accountable when the first batter to whom he
pitches reaches first base on four called balls if such batter has a decided advantage
in the ball and strike count when pitchers are changed.
(1) If, when pitchers are changed, the count is
2 balls, no strike,
2 balls, 1 strike,
3 balls, no strike,
3 balls, 1 strike,
3 balls, 2 strikes,
and the batter gets a base on balls, the official scorer shall charge that batter
and the base on balls to the preceding pitcher, not to the relief pitcher.
Rule 10.16
115
(2) Any other action by such batter, such as reaching base on a hit, an error, a
fielder’s choice, a force-out, or being touched by a pitched ball, shall cause
such a batter to be charged to the relief pitcher.
Rule 10.16(h) Comment: The provisions of Rule 10.16(h)(2) shall not be construed as affecting or
conflicting with the provisions of Rule 10.16(g).
(3) If, when pitchers are changed, the count is
2 balls, 2 strikes,
1 ball, 2 strikes,
1 ball, 1 strike,
1 ball, no strike,
no ball, 2 strikes,
no ball, 1 strike,
the official scorer shall charge that batter and the actions of that batter to the
relief pitcher.
(i) When pitchers are changed during an inning, the relief pitcher shall not have the
benefit of previous chances for outs not accepted in determining earned runs.
Rule 10.16(i) Comment: It is the intent of Rule 10.16(i) to charge a relief pitcher with earned runs
for which such relief pitcher is solely responsible. In some instances, runs charged as earned against the
relief pitcher can be charged as unearned against the team. For example:
(1) With two out and Peter pitching, Abel reaches first base on a base on balls. Baker reaches
first base on an error. Roger relieves Peter. Charlie hits a home run, scoring three runs. The
official scorer shall charge two unearned runs to Peter, one earned run to Roger and three
unearned runs to the team (because the inning should have ended with the third out when
Baker batted and an error was committed).
(2) With two out, and Peter pitching, Abel and Baker each reach first base on a base on balls.
Roger relieves Peter. Charlie reaches first base on an error. Daniel hits a home run, scoring
four runs. The official scorer shall charge two unearned runs to Peter and two unearned runs
to Roger (because the inning should have ended with the third out when Charlie batted and
an error was committed).
(3) With none out and Peter pitching, Abel reaches first base on a base on balls. Baker reaches
first base on an error. Roger relieves Peter. Charlie hits a home run, scoring three runs.
Daniel and Edward strike out. Frank reaches first base on an error. George hits a home run,
scoring two runs. The official scorer shall charge two runs, one of them earned, to Peter,
three runs, one of them earned, to Roger and five runs, two of them earned, to the team
(because only Abel and Charlie would have scored in an inning reconstructed without the
errors).