Here's the rule:
Independent Clause, but Independent Clause.
Example:
* I love to eat ice cream, but I try to limit my intake.
Exceptions:
You don't need a comma before "but" if:
* The two clauses are very short and simple.
* The second clause is a dependent clause.
Examples:
* I love to eat ice cream but not every day. (Short clauses)
* I love to eat ice cream but only when I'm out with friends. (Dependent clause)
Let me know if you have any other grammar questions!