Under the 2018 Rules, players are only allowed to substitute a ball when taking relief under a few specific Rules. Substitution is allowed when taking penalty relief, such as when a ball is lost in a water hazard, unplayable, or lost or OB. Substitution is not allowed when taking free relief, such as from an immovable obstruction, ground under repair, and so on if the ball is relatively easily recoverable.
In 2019 under Rule 14.3, players will always be allowed to substitute a ball or use the original ball in all relief situations. Players will also be able to take relief any other time they’re required to drop and play a ball, such as when a previous stroke is canceled or the player returns for another reason to a place from which a previous stroke was made.
The USGA and R&A cited a few reasons for this change. First, there was often confusion over whether players could substitute a ball or had to use the original depending on the specific circumstances. This change grants the player the right to substitute when taking relief, whether penalty relief or not. (The Rules would often say “a ball” or “the ball” to differentiate between whether a ball may be substituted or not.) The change also eliminates worrying about whether a ball is “immediately recoverable” or not.
Note that this Rules change does not permit substitution when a ball must be replaced after it was lifted or moved. In this case, the Rules require use of the original ball, with no substitutions (except as allowed under the exceptions under 14.2a).
https://www.youtube.com/watch?v=V-jO0A7ZPoY
It might be worth noting that this also applies when taking a preferred lie.