Ago and back (informal) are used for past times from the present moment:
- I graduated from high school ten years ago.
(ten years in the past from today)
- We sent the package three days ago.
(three days in the past from today)
- I moved here about five years back.
(informal – five years in the past from today)
Before and earlier are used for past times from another time in the past.
Here are some examples:
- Yesterday I missed my train. I got to the train station at 7:10, but the train had left ten minutes before. (or ten minutes earlier)
(= at 7:00, ten minutes before 7:10 yesterday)
- I was very happy when I got this job last June, because I had lost my previous job six months before. (or six months earlier).
(= six months before last June)