What to optimize for when asked to find the most important features I have a binary classification problem, let's say people can buy or not buy a certain product. Now unlike a standard prediction task, I only want to find which features are the most important for the person's decision to buy.

Which metric should I use to optimize the algorithm? Maximize out of sample accuracy like when I would be interested in making the best prediction? Or maximize fit and don't care about overfitting? A mixture of both?

I am using xgboost.
Ideally you should select features in the same way you select the best model hyperparameters, with a validation set. 

You are interested in how the features work on unseen data, not your training data.

Depending on your feature selection algorithm, feature search will be intractable with larger data.  Naive feature selection is O(2^n) AND some model hyperparameters could be dependent on your choice of features.