Is it legal to put oil in soil?

No it is not legal, it is a violation of Environmental laws to dump oil into the soil or rivers.