Both whether and if can be used to introduce indirect yes/no questions.
- I don’t know whether I can come. OR I don’t know if I can come.
- I don’t know whether I will have time. OR I don’t know if I will have time.
After some verbs, whether is preferred to if.
- We discussed whether we should move to another city. (More normal than ‘We discussed if we should…)
Whether is usually preferred in a two-part question with or.
- I don’t know whether I should accept or refuse. OR I don’t know if I should accept or refuse.
If cannot be used after prepositions.
- We haven’t settled the question of whether we should move to a bigger city. (NOT We haven’t settled the question of if we should move to a bigger city.)
Whether is used before to-infinitives. If cannot be used before to-infinitives.
- I don’t know whether to accept or refuse. NOT I don’t know if to accept or refuse.
If is not normally used to introduce a clause used as subject or complement.
- Whether we can trust our guide is another matter. (More natural than ‘If we can trust our guide is another matter’.)
- The question is whether our guide can be trusted.
Note that if is possible in a very informal style.
- The question is if our guide can be trusted.