In both cases you have a conditional sentence.
What if means What will/would happen if... You are right when you say it is used in a question. If on the other hand is used to introduce a conditional clause, not necessarily a question. Here are two examples:
If I told you the truth, what would you do?
You can also have a positive or negative sentence with if of course, as you suggested in your question: If I told you the truth, you'd be hurt. OR If I didn't tell you the truth, I would feel awful.
What if I told you the truth? (This implies the question of what you would do or what would happen.)