This procedure is for indefinite integrals. See the procedure for definite integrals for how to handle integration with limits by substitution.
There is no set rule for how to make this choice, so you may have to make several tries. A good rule of thumb is that if there is a function of something other than x, (e.g., cos(2x+1)) or a power of some function of x or a root of a function of x, then these functions are good candidates for u.
This expression should appear as part of the integral. If it doesn't, you may have chosen a bad u. If the integral is missing some constant multiplier, you can fix it by multiplying by this factor inside the integral and dividing by this factor outside the integral.
You should be left with no x's in the integral. If you have x's left over, you may be able to solve for x in your equation for u and replace them, but this doesn't always work.
If you end up with extra x's, or without the proper du/dx, then you should go back and try a different u.
Note: there is no guaranteed way to choose the proper u; it takes experience and sometimes a little creativity. Keep trying if it doesn't work at first.
Note: the method of substitution does not work for all integrals (only on those functions that are the result of a chain rule derivative; not all functions are). If you can't get a substitution to work, try another integration technique.