These two abbreviations get confused a lot, and not just by English language learners! The problem is that they come from Latin and not very many people actually speak or understand Latin anymore.This means “id est”, which translates more or less to “that is” or “in other words”.
This is used to clarify a statement you have already made, and offer further explanation. If you replace i.e. with “in other words” the sentence will still make sense.
I hate playing most team sports (i.e., soccer, basketball, baseball and hockey).
Everyone affected by this flight delay will receive the same compensation; i.e., a coupon for dinner and a hotel voucher.
This means “exempli gratia”, which translates more or less to “for example”.
This is used to introduce an example. If you replace e.g. with “for example”, the sentence will still make sense.
My daughter won’t eat any vegetables (e.g., spinach or broccoli).
They always give out terrible prizes at these events; e.g., cheap pens, lollipops and other small things.
I hope this helps clear up how to use these two. Please let me know if you have any more questions about this.