I think the word "but" is a conjunction. Can someone explain me when in English we put a comma before it and in what cases we do not do this?
The comma must be used before "but" when this word is separating two independent clauses. For example:
"I like sunny days, but Carla prefers the rain."
In this case "I like sunny days" and "Carla prefers the rain" are two valid, therefore independent, sentences. For this reason you must use a comma before the word "but".
Now look at this other sentence:
"I like sunny days but Carla, the rainy ones."
Notice that "Carla, the rainy ones" is not a valid and independent clause, it depends on the first clause to make sense, so no comma is used before the word "but".