A macro can't check whether your totems are placed or not. Best I can think of is:
/castsequence reset=alt Call of Earth, Totemic Recall
Simple enough, this macro casts CoE on the first press, and TR on the second. If you ever need to reset it manually to start at CoE again, hold alt (can be changed to whatever modifier you prefer) and press the macro again.