I think this one comes from hunting and describes the perked up ears of the hunting dog. We say it if a situation doesn't really look like any positive change is to be expected and we just want to encourage the other not to lose hope. Or if something just takes painfully long. Or just as a general thing to say if parting ways with someone (what's the opposite of a greeting called?).