Only if you come, will I go out
Solution 1:
Both sentence have the same syntactical construction. Therefore, it's a logical contradiction to claim that one must have a comma while also claiming that the other must not. So, based only on that, your teacher's claim is illogical.
Only if you come, will I go out.
Is only if you come a dependent clause?
Consider this:
Will I go out.
As a statement, this is not a proper sentence because it is not an independent clause (it does not stand on its own in a meaningful way).
Only if it were a question is it something that could stand on its own as an independent clause:
Will I go out?
But you can't have a grammatical sentence that is formed only of dependent clauses. You can have a dependent clause, but only if there is also another portion of the sentence that is an independent clause.
As standalone fragments, both of these could be considered to be dependent clauses:
only if you come
will I go out
But if we stick them together into a single sentence, and we know that the sentence itself is grammatical, then we cannot separate one of the fragments from the rest.
As a result, the entire sentence must be a single, independent clause rather than either component being a dependent clause:
Only if you come [,] will I go out.
No portion of this sentence is a dependent clause.
Given this, there is no dependent clause followed by an independent clause that would warrant a comma.
Nor is the comma being used in the formation of a series of list items or to set apart parenthetical information:
✔ Only if you come, bring me some money, and book us a reservation, will I go out.
✔ Only if you come, and come soon, will I go out.
In every way I look at it, the use of the comma in your first sentence is not something that should be used.
Therefore, I conclude this about the grammar of the various sentence forms:
✘ Only if you come, will I go out.
✘ Only if you are a member, can you borrow books.✔ Only if you come will I go out.
✔ Only if you are a member can you borrow books.