3.7 V battery charging
You are probably very badly wrong about your battery.   

IF it is a Li-Ion battery :- 


the MEAN voltage is 3.7V, 
the ABSOLUTE MAXIMUM voltage is 4.2V, and 
the working range is typically about 3.0 -  4.2V 


ABSOLUTE MAXIMUM
MEANS
ABSOLUTE
MAXIMUM

Exceeding 4.2V is a fatally bad idea.

Applying 5V to the battery will destroy it.
You protect against 5V by NEVER applying it.
There are a VAST number of LiIon chargers and charger ICs available.
Using one of these is the usual approach. 

You COULD design your own from scratch, but you need to have a very good idea of what is involved, and it seldom makes economic or other sense to do so.