お元気で could be paraphrased as
お元気で would be used when you won't see someone for a while and you are basically saying "stay healthy".
気をつけて could be paraphrased as
気をつけて is used when seeing someone off, in other words, you know the person is from this point on is going on a trip overseas, or is going to get in their car and drive home. It implies the idea of "be careful on your trip (or when driving home)".
So to distinguish the two, if you are not sure what the person is going to be doing from the point you part ways, お元気で would be more appropriate.
お元気に as Chocolate mentions is not used by itself like that. However, you could see it in phrases like 早くお元気になってください or お元気になさっていますか.