These mean exactly the same thing, except when they don't. :)

From TheFreeDictionary.com

-gram suff. 1. Something written or drawn; a record: cardiogram. -graph suff. 1. Something written or drawn: monograph.

This would seem to indicate that they are the same. And, in fact, if you look up pictograph and pictogram you see those words are synonyms. However, if you try to apply the logic to all words formed with the -gram/-graph suffix, you run into trouble:

ep·i·gram (p-grm) n. 1. A short, witty poem expressing a single thought or observation. 2. A concise, clever, often paradoxical statement. See Synonyms at saying. 3. Epigrammatic discourse or expression. ep·i·graph (p-grf) n. 1. An inscription, as on a statue or building. 2. A motto or quotation, as at the beginning of a literary composition, setting forth a theme

So you really have to learn which is which on a case-by-case basis. Sorry.

BTW, the etymologies are different:

-graph[French -graphe, from Late Latin -graphus, from Greek -graphos, from graphein, to write; see gerbh- in Indo-European roots.]

-gram [Greek -gramma, from gramma, letter; see gerbh- in Indo-European roots. Sense 2, from telegram.]