This can be done by doing the first few derivatives and discerning a pattern. We begin with f'(x).
f(x) = xex
Using the Product Rule [(uv)' = uv' + vu'], we can set u = x and v = ex, and therefore, u' = 1 and v' = ex.
This makes the derivative f'(x) = xex + ex = ex(x + 1).
Next we find f''(x). f''(x) = ex + ex(x + 1) = ex(1 + x + 1) = ex(x + 2).
We'll do one more, since that is what the question calls for.
f'''(x) = ex + ex(x + 2) = ex(1 + x + 2) = ex(x + 3).
The pattern that is emerging is that, with each new derivative, a new ex gets added, or the constant inside the binomial (which multiplies by ex) increases by 1. In fact, the constant inside the parenthesis is the same number as the number of derivatives that you've done. So the general formula would be f(n)(x) = ex(x + n).