How does the meaning differ in these sentences when I use a comma?
If you prefer this cake would be fine.
If you prefer, this cake would be fine.
The meaning doesn't change: but the comma makes the sentence easier to read.
Without the comma after "prefer", most readers will read on thinking that "this cake" is part of the subordinate clause. They will expect a sentence like this:
If you prefer this cake, you can have it.
But the sentence isn't constructed that way at all. "This cake" is actually the subject of the main clause. When the reader gets to the verb phrase "would be", he or she will have to revise his or her understanding of the whole sentence, most likely jumping back to the beginning of the sentence and reading it again.
The comma marks the end of the subordinate clause. It is a basic courtesy to the reader to include that comma if a sentence begins with a subordinate clause.