The Use of i.e. and e.g. correctly

I.e. indicates that is, and, e.g. means for example.

How to fix it
Whenever you write it, reread the sentence in your head with the full version, that is where the shortened version (i.e.) is. If it doesn’t make sense, then change it.
Additional tip:
While not a universally used convention, I recommend punctuating like this:
e.g.,        i.e.,

Why? If you were writing for example in a sentence, how would you write it?
For example,        that is,

You would include commas, right? So why wouldn’t you contain commas in the shortened versions? Plus, you look like you know about grammar, and that’s always a positive.