This is based on the principle of "like dissolves like". Ethyl alcohol and water are both polar in nature, and thus are of same type. So they mix uniformly and produce a homogeneous solutiom. Oil and water, on the other hand are of opposite nature as water is polar but oil is non-polar. So, they do not mix and the layer separates them in a solution. So, they form a heterogeneous solution.
Hope this helps:)