What is a term for a word or phrase whose literal wording differs from its actual meaning?

It's called a misnomer - the name doesn't match the named.

Misnomer noun A wrong or inaccurate name or designation: ‘King crab’ is a misnomer—these creatures are not crustaceans at all - ODO

Here are some examples from wikipedia:

  • Catgut is made from sheep intestines.
  • French horns originated in Germany, not France.
  • The "funny bone" is not a bone—the phrase refers to the ulnar nerve.

In general this is called a paradox or contradiction. Your example is actually an outdated term as originally black boxes indeed were black.

paradox
http://www.oxforddictionaries.com/definition/english/paradox

A seemingly absurd or contradictory statement or proposition which when investigated may prove to be well founded or true:
the uncertainty principle leads to all sorts of paradoxes, like the particles being in two places at once

contradiction
http://www.oxforddictionaries.com/definition/english/contradiction

A combination of statements, ideas, or features which are opposed to one another:
the proposed new system suffers from a set of internal contradictions

origin
http://guardianlv.com/2014/03/why-are-cockpit-voice-recorders-painted-orange-and-called-a-black-box/

While a modern-day black box is painted bright orange to help investigators find them, early versions were painted black, and the name stuck.


I suggest that this is an idiom:

Idioms are a group of words established by usage as having a meaning not deducible from those of the individual words. Example of idioms are "rain cats and dogs" and "see the light."

There are several lists of idioms on the Internet, including:

  • Idioms and phrases from The Free Dictionary
  • List of English-language idioms in Wikipedia

It's all there in the tag definition on this very website!