This syntax should work
If(Num([COD. COMPANY]) = 11 AND BRANCH = 517, 517, // When condition is true If(Num([COD. COMPANY]) = 11 AND BRANCH = 518, // When condition is false, nest a new If() 518, 'Other') ) AS COMPANY
Anyway, depending on your data model there might be some easier solution, probably using mapping tables, joins and so. Having complex conditionals may perform really poor and it make the script to take longer to load.
Hope that helps.