The most important elements besides carbon and hydrogen contained in crude oil are the following: sulfur, vanadium, sodium and potassium. One can only speculate about origin.
Metal cations like Na, K, Ca, Mg and Li (some 1000 to 10 mg/kg) can be found in dependance of geochemical composition. Their origin is from salts (e.g. Muschelkalk in the Molasse basin).