**Neither a teacher nor a native speaker.**
I think "only if" is a condition and "if only" is a wish.
I will give you the money only if you do your work properly.
Only if you tell me his name, I will let you go.
If only I had the chance to work...
(Said by an unemployed who finally wants to work.)
If only she were here, I would be so happy.
(The wish that a certain person is near you.)
P.S: It's an interesting question and I hope I am right
Student or Learner