What is the difference between a generalization and an extension?
Solution 1:
Let's start with two examples:
Suppose you have a function $f\colon(0,1)\to\mathbb R$. You can turn this into a function $\tilde f\colon\mathbb R\to\mathbb R$ by defining, for example, $\tilde f(x)=f(x)$ when $x\in(0,1)$ and $\tilde f(x)=0$ otherwise. The function $\tilde f$ is an extension of $f$, not a generalization.
Maybe you have proved earlier that if $x\leq y\leq x$ for some real $x$ and $y$, then $x=y$. But in fact the same holds true if $x$ and $y$ are matrices. There is a natural definition of "$\leq$" for matrices. In the case of $1\times1$ matrices you get the original version back. The result for matrices is a generalization of the result on the real line. I would not object to calling this an extension, but I would prefer to use the word "generalization" instead.
I would say that in general objects are extended and results are generalized.
You might want to extend your field from the reals to the complex (or make some other field extension), or you might want to extend the domain of definition of some function. Generalization is a more general result that contains the original result as a special case. If the original result is not included, I would not call the new result a generalization but and analogous result inspired by the original. Similarly, if a new function is somehow inspired by an old one but does not "contain" it, I would prefer to call it an induced function rather than an extension.
Solution 2:
I agree with Joonas that "extension" can be used to refer to objects, such as functions extended to a larger domain while preserving some properties, or in field extensions (a larger field containing the original one). However, we do often use the same word to refer to generalizations of a theorem as well, namely we could say something like "We can easily extend this result to an arbitrary metric space.". Hence you see things like "extended mean-value theorem" and "extended Bayes theorem" and "extended Green's theorem". Also, the Wikipedia article about the binomial theorem even uses both words together: "The generalized binomial theorem can be extended to the case where x and y are complex numbers.".
The bottom line is that the words "generalization" and "extension" turn out to just have the natural English meaning even when used in mathematics, most of the time. It may nevertheless be worth pointing out that there is one technical meaning of "extension" in the field of logic, which has little to do with the common English meaning.
Solution 3:
Let us think of a mathematical object as a set on which some operations are defined. An extension is a bigger object of which the original object is part, while a generalization is a less tightly defined object, of which the original object is an example. In an extension, the operations defined on the original set are extended to apply in a similar manner to the extended set. In both cases, some of the characteristic properties of the original operations hold, but generally not all of them.
The canonical example is the counting numbers: $1$, $2$, $3$, ... . This set ($\Bbb Z_+$) of numbers is extended first by $0$ to the natural numbers ($\Bbb N$) and then by the negative numbers to form the integers ($\Bbb Z$). The latter set may naturally be generalized to varying degrees; in particular, it is an example of a commutative ring with identity, which is not a completely defined object. Another example of such a ring is the ring of polynomials in one variable over the integers, $\Bbb Z[x]$, which is itself an extension of the integers. But not all cases of a generalization need to be an extension: for instance, the "clock-arithmetic" ring $\Bbb Z_{12}$ is not an extension of $\Bbb Z$.