Hi Tereza,
Sometimes, they can be used interchangeably. Sometimes, only one of them should be used. For example, "if" is used in conditional sentences while "whether" is used to express the idea of two possibilities.
Example (where "if" is preferred):
"If I practise, I will improve." Here, the condition of constant practice must be satisfied before I can see any improvement. It is inappropriate to use "whether" here (Whether I practise, I will improve).
Example (where "whether" is preferred):
"Let John know whether you can meet his deadline." Here, there are two possibilities: you can meet his deadline OR you cannot meet his deadline. Either way, you have to inform John.
Other examples: (1) "Let John know if you can't meet his deadline." Here, you only need to inform John in the event that you cannot meet his deadline. // (2) "Let John know if you can meet his deadline." Here, "if" expresses the same meaning as "whether" (two alternatives). // (3) "Let John know whether you can't meet his deadline". No one writes in this way as "whether" already expresses both positive and negative alternatives.
Both "if" and "whether" can also be used interchangeably in reported speech to express two alternatives.
Example:
Mom asked, "Can you come home earlier today?" (direct speech)
Mom asked if/whether I could come home earlier that day. (reported speech)
Take note of the expression "whether or not". It is used to express the idea that it doesn't matter which of two alternatives possibilities or states is true as the outcome will be the same.
Example:
We are going outdoors if it rains. (If it does not rain, we will stay indoors.)
We are going outdoors whether or not it rains. (We will go outdoors, and we don't care if it rains or not.)
In a nutshell, use "if" if you are writing conditional sentences; use "whether" to express two alternatives.