Many things can cause this including change in diet, fillings, copper cookware, but I would look for an abscess which may "weep" and cause this taste before it gets painful.
Ketosis can occur when the body is burning fat or consuming muscle. This can happen if you aren't eating enough carbohydrates (at least 30 grams a day or more). It can also arise from bacteria on the tongue. A tongue scraper can be an easy solution. Moderation and variety in the diet are the keys.