The formal rule is to use IF when you have a conditional sentence and WHETHER when you are showing that two alternatives are possible. Some examples will make this more clear.
ex: “The President didn’t know WHETHER the zombie attack would begin on Monday or Tuesday.” Because I used “whether,” you know that there are two possibilities: Zombies will attack Monday OR Zombies will attack Tuesday.
Now see how the sentence has a different meaning when I use IF instead of whether:
“The President didn’t know IF zombies would attack on Monday or Tuesday.” Now, in addition to attacking on Monday or Tuesday, it’s possible that zombies may not attack at all.
Here’s another example:
“Call the President if zombies are going to attack on Monday.”
“Call the President whether or not zombies are going to attack on Monday.”
The first sentence is conditional: call the President only if zombies are going to attack. The second sentence is not conditional: call the President either way.
However, there are some circumstances when whether and if can be used interchangeably, notably when answering a yes/no question. For example:
Are you going to the concert?
— I am unsure whether I will be going to the concert.
— I am unsure if I will be going to the concert.
(In both sentences, the meaning is that I may or may not attend the concert.)
Did you turn off the oven when you were finished?
— Mary wondered whether she had turned off the oven.
— Mary wondered if she had turned off the oven.
(In both sentences, the meaning is that Mary may or may not have turned off the oven.)
Basic rule: use WHETHER when you have two distinct choices or mean “regardless of whether,” and use IF for conditional sentences.