NP-hardness is a category that applies to both decision problems and optimization problems. In contrast, NP-completeness is a category that applies only to decision problems.
Here are the relevant definitions:
- A decision problem is in NP if it is accepted by some polynomial time nondeterministic Turing machine.
- A decision problem is NP-hard if all problems in NP can be reduced to it in polynomial time.
- A decision problem is NP-complete if it is both in NP and NP-hard.
- An optimization problem "max $f(x)$ subject to $x \in X$" is NP-hard if the decision problem "given $x$ and $y$, does there exist $x \in X$ such that $f(x) \geq y$?" is NP-hard.
- An optimization problem "min $f(x)$ subject to $x \in X$" is NP-hard if the decision problem "given $x$ and $y$, does there exist $x \in X$ such that $f(x) \leq y$?" is NP-hard.
The decision problems used to define NP-hardness for optimization problems are known as decision versions of the optimization problems.
One could extend the definition of NP to optimization problems in various ways. For example, we could say that "max $f(x)$ subject to $x \in X$" is in NP if its decision version is in NP. This would also allow us to define NP-completeness for optimization problems. But for some reasons these definitions are not standard.
Let me also mention FNP, an extension of NP to functions.