You can use whether or if interchangeably in indirect questions. "If’ is more informal and more common in spoken English. "Whether" is more formal and should be used in formal writing.
Do you know if/whether he has a girlfriend?
Could you tell me if/whether the supermarket is open on Sundays?
I was wondering if/whether you'd like to join me for lunch.
There are some cases where we MUST use whether:
Before infinitives (to + verb)
I don't know whether to tell him or not. or I don't know if I should tell him or not.
She's trying to decide whether to travel or continue her studies. or She's trying to decide if she should travel or continue her studies.
After prepositions (about, on, over, etc.)
We're thinking about whether we'd rather go out or stay in tonight.
It depends on whether it'll be rainy or sunny.
Always use if to introduce a condition, in a conditional sentence:
My boss gets mad if I'm late for work.
(Condition = I'm late for work. Result = my boss gets mad)
If you drive me to the airport, I'll give you $15 for gas.
(Condition = you drive me to the airport. Result = I'll give you $15)
I'd surf every day if I lived near the beach.
(Condition = living near the beach. Result = surfing every day)
If we'd left home earlier, we wouldn't have missed our flight.
(Condition = leaving home earlier. Result = not missing the flight)