I understand that before feature engineering one has to split the dataset into train and test data, so as to avoid bias in the analysis. I also understand that the machine learning model does not understand data apart from numerical data, thus encoding is required, which is a part of feature engineering. My question is, do I encode the test data separately or does the prediction function understand categorical data.
This depends somewhat on the model and language (implementation).
First please understand that categorical data is not the same as non-numerical data! Many models can handle categorical data (e.g. regression formats) just fine and some can even handle non-numerical data.
Finally and most important for you feature engineering has to be done on the whole data set before the train/test split. All models can only predict on data that has the exact same input formats as the data it has been trained on!
So yes if you one-hot encoded some column it also needs to be one-hot encoded for the prediction.