Given two real numbers $a, b$ with $a \neq 0$, find all polynomials $P(x)$ which satisfy
\[xP(x - a) = (x - b)P(x).\]
We are given the functional equation for a polynomial \( P(x) \):
\[ xP(x - a) = (x - b)P(x). \]

We need to find all polynomials \( P(x) \) that satisfy this equation.

1. **Case 1: \(\frac{b}{a} \not\in \mathbb{N} \cup \{0\}\)**

   If \(\frac{b}{a} \not\in \mathbb{N} \cup \{0\}\), then \( b \) is not a multiple of \( a \). We can show that \( 0, a, 2a, \ldots \) are roots of \( P(x) \). 

   - For \( x = 0 \):
     \[ 0 \cdot P(-a) = (-b)P(0) \implies P(0) = 0. \]
   - For \( x = a \):
     \[ a \cdot P(0) = (a - b)P(a) \implies P(a) = 0. \]
   - For \( x = 2a \):
     \[ 2a \cdot P(a) = (2a - b)P(2a) \implies P(2a) = 0. \]
   - Continuing this process, we see that \( P(ka) = 0 \) for all nonnegative integers \( k \).

   Since \( P(x) \) has infinitely many roots, it must be the zero polynomial:
   \[ P(x) \equiv 0. \]

2. **Case 2: \( b = ka \) for some \( k \in \mathbb{N} \cup \{0\} \)**

   - **Subcase 2.1: \( k = 0 \)**
     \[ xP(x - a) = xP(x). \]
     For \( x \neq 0 \), we have:
     \[ P(x - a) = P(x). \]
     This implies that \( P(x) \) is periodic with period \( a \). Since \( P(x) \) is a polynomial, the only periodic polynomials are the constant polynomials. Therefore, \( P(x) \) is a constant polynomial.

   - **Subcase 2.2: \( k > 0 \)**
     Let \( b = ka \). The equation becomes:
     \[ xP(x - a) = (x - ka)P(x). \]
     Since \( x \mid P(x) \), we can write \( P(x) = xQ_1(x) \). Substituting this into the equation, we get:
     \[ x(x - a)Q_1(x - a) = (x - ka)xQ_1(x). \]
     Dividing both sides by \( x \):
     \[ (x - a)Q_1(x - a) = (x - ka)Q_1(x). \]
     For \( k > 1 \), we see that \( x - a \mid Q_1(x) \). We can write \( Q_1(x) = (x - a)Q_2(x) \). Repeating this process, we define \( Q_3(x), Q_4(x), \ldots \) until \( Q_k(x) \), which satisfies:
     \[ (x - ka)Q_k(x - a) = (x - ka)Q_k(x). \]
     This implies that \( Q_k(x) \) is constant. Therefore, we have:
     \[ P(x) = Ax(x - a)(x - 2a) \cdots (x - (k - 1)a), \]
     for some constant \( A \).

The final answer is \( \boxed{ P(x) = Ax(x - a)(x - 2a) \cdots (x - (k - 1)a) } \) for \( b = ka \) and \( P(x) \equiv 0 \) for \(\frac{b}{a} \not\in \mathbb{N} \cup \{0\} \).