When to do feature encoding with XGBoost, random forest

Hi I would like to understand when it is necessary to do feature encoding. For example, I am using models like XGBoost and Random Forest. Do I need to encode categorical variables? For instance, if I have a variable like ‘education’ with levels: high-school, bachelor, master, phd, should I recode the feature as: high-school=1, bachelor=2, master=3, phd=4? Or is it better to use one-hot encoding, creating 4 new columns? What if the categorical variable doesn’t have a natural order, like ‘country of birth’? In this case, is it correct to only apply one-hot encoding?