It is one of the most frequently asked questions that come to the group when someone has been here for a while and starts looking for something better. "I have a B permit. Can I change employers without risking the permit?"
The answer depends on where you were born, although it's surprising how many people don't know. If you are a citizen of an EU or EEA country, and Spaniards enter here, the B permit does not tie you to the employer. The Free Movement Agreement between Switzerland and the EU expressly states that you have the right to change jobs and companies with total freedom, as long as you continue to work. No prior authorization required. In practice, the usual thing is to communicate the change to the cantonal migration office, which updates your data, but they cannot prevent the change or condition the permission for having done so.
The limit to know: permit B is linked to the existence of an active employment relationship. If at any time you are involuntarily out of work for more than twelve consecutive months, renewal may be limited to one year instead of five. It is not automatic, but it is a factor that the canton can take into account.
The situation is completely different for people from countries outside the EU/EEA, whose B permit is generally linked to the employer and the sector of activity. Changing companies requires a formal authorization process, and is not guaranteed.
So if you're Spanish, you don't have to ask your current company for permission to look for something new. What you do need to do is make sure the new contract is signed before you leave the old one. The chain cannot be broken.