It is one of the most frequent and poorly answered questions in help groups. The short answer: You don't lose your permit, but you have specific obligations and deadlines to meet, and that varies depending on the situation.
If you are a European citizen with a B permit and you change employers, you can do so freely in principle. The EU/EFTA citizen permit B is not linked to a specific employer. But you must notify your canton's immigration office of the change, usually within two weeks. Failure to do so does not automatically cause you to lose your permit, but it does put you in an administrative situation that can complicate future paperwork, especially if you are accruing years toward a naturalization or C permit application.
If the job change also includes moving to another canton, it requires a bit more attention. The permit is not automatically transferred between cantons: you must register in the new municipality within 14 days of arrival, and the cantonal immigration office of the new canton will process the continuity of the permit. This is not a new request from scratch, but it is an active process. The C permit is also no exception: the change of canton must also be communicated, although it gives more leeway.
What should be avoided is staying months without communicating anything because "total, the permit is still in force". The permit may still be in effect, but administrative history matters. And when it's time to renew, apply for C, or start naturalization, the system already knows whether you communicated the changes or not.