LM317 circuit capacitor question
The two capacitors used in the LM317 typical application are described on page five of this datasheet. An identical schematic to the one you provided is given:
Along with a helpful note about why the capacitors are needed:
Note: 3. \$C_i\$ is required when the regulator is located an appreciable distance from power supply filter. \$C_O\$ is not needed for stability; however, it does improve transient response. Since \$I_{ADJ}\$ is controlled to less than 100 μA, the error associated with this term is negligible in most applications.
The best practice, for either capacitor, is to always include them. Specifically for \$C_i\$, place it as close to the input pin on the LM317 as reasonable.
If you have determined that you know what you're doing, you can decide to omit or alter the suggested schematic. In determining that, for \$C_i\$, an appreciable distance in on the order of centimeters, but you should also factor in the level of noise you expect on the input supply and how much the load the LM317 will be changing. For \$C_O\$, you can likely omit it if you have decoupling capacitors at the inputs of any ICs and relatively high current draw devices, anywhere things are going to be changing how much current they're drawing in a short amount of time.
Do check out the related questions and answers regarding how to use decoupling capacitors and how to select the type of capacitors to use.