Simplified but:
Senpai is used to call someone who is your senior (someone older or has more experience than you) in a certain field like at a school or workplace (e.g. “Tanaka-senpai”).
Sensei is the one used for your teachers or doctors (e.g. “Takeda-sensei”). Sensei is basically used for someone who's a master at what they do or has a specialized degree.