I.e. stands for the Latin id est, or 'that is,' and is used to introduce a word or phrase that restates what has been said previously. What follows the i.e. is meant to clarify the earlier statement:
Research at three British zoos suggests that meerkats "showed increased positive interactions" (i.e. they were happier) when human visitors returned than they were during the visitorless lockdown.
— Peter Rhodes, Shropshire Star (Telford, England), 5 Mar. 2021
I.e. is similarly useful for defining or explaining a term or concept whose meaning readers might not know:
Take butterflied — i.e. deboned — whole fish, sprinkle it with lime and orange juices, and sumac, and then bake for about 10 minutes.
— Emily Weinstein, The New York Times, 10 June 2022If your home has “hard water” (i.e., a high mineral content), your sinks, showers, and tubs no doubt bear white or yellow buildup as a result. — Melissa Reddigari, BobVila.com, 22 Aug. 2019
While i.e. is often set off by brackets or parentheses, it can also sometimes follow a comma or em dash. It is usually followed by a comma.
E.g. means “for example.” (It stands for exempli gratia in Latin.) It is used in much the same ways as 'for example,' coming before an item or list of items.
Set an immediate timeline, e.g., three weeks, to learn all this.
— Waterloo Region Record (Kitchener, Canada), 12 July 2022WIPA will launch a 12-week choral program for up to 60 older adults that explores musical themes (e.g., Jazz, Rock, Great American Songbook, Classical) chosen by the participants.
— Courier-News (Bridgewater, NJ), 2 July 2018
E.g. is similar to i.e. in the way it is punctuated: it is often placed inside brackets or parentheses, and can sometimes follow a comma or em dash. It is also usually followed by a comma.
It may help to remember that both 'that is' and 'for example' function in English in the same way as i.e. and e.g.. If you feel uncertain try substituting ‘that is’ for i.e., or ‘for example’ for e.g.; if your sentence still makes sense you’ve used the right one.