e.g. is used for one example from what could be a longer list.
i.e. is used for when you want to define one thing specifically.
Example: The person writing this (i.e., Kevin Grandfield) is an editor (e.g., Kevin Grandfield). (I am the only person writing this, but there are other editors.)
One way to remember is thinking of e.g. in English as short for “example given.”
The small print: e.g. is short for the Latin phrase “exempli gratia” or “free example.” i.e. is short for the Latin phrase “id est,” literally “that is.” So you use it the way you would the English phrase “that is”; that is, you use it to define specifically or explain further.
One last note: I have seen an increase in people separating these from surrounding text by using commas. The traditional way (and clearer way, if you ask me) is to always enclose them in parentheses (i.e., like this).