Is there a light that indicates charging? I know with my super cheap earbuds I rely heavily on that light to avoid the problem you describe...
I've dealt with this occasionally, from what I suspect is some buildup on the contacts due to sweat on my headphones from running. I find taking a cotton swap with alcohol to clean off the contacts every so often solves the problem.