if / whether
A condition versus an alternative.
Use if for a condition: If it rains, cancel the picnic. Use whether for alternatives, especially after verbs of asking and knowing: I asked whether the lock held. Whether is the word when or not is expressed or clearly implied. If in place of whether is common. Whether is the tighter word.
Examples
UseIf the lock fails, call her.
UseI asked whether the lock failed.
AvoidI asked if the lock failed. (If you mean the alternative, not a condition.)