Do you have to turn off electricity to change a doorbell?

Yes, the wire attached to the doorbell does carry an electric current and you can get a shock if you work on it without turning off the power first. Ideally, you should locate the specific fuse or circuit breaker for that particular wire, so you don't have to turn off all the power to the whole house. Be careful; electric shock can be very dangerous.