They are abbreviations of latin terms.
I.e. is for "id est" which can be translated as "which means" or "that is". You can use it in English when the reader needs to "get it", i.e. understand the meaning.
E.g. is for "exempli gratia" which is, as you say, "for example". You can use this in many English sentences, e.g. this example.
Edit: Ninja'd, what student88 said!