When should I knead with oil and when with flour?
Both messes up the ratio, as you said, so you shouldn't use anything during kneading. You only need to use a little bit of something during shaping. With some pastries, the shaping is extensive and you get lots of the smoother worked into the dough; this is expected and desired (e.g. in strudel sheets). 

Properly kneaded bread dough does not stick to anything, even if it started out very wet. So, if it sticks at the beginning, just continue kneading until it stops (I knead it between my hands then, not on a surface). When it is ready, it will not only stop sticking to your hands, but also pull the smear of the hand surfaces into itself, coming clean off them so you can work with it. (You will still have to clean your hands afterwards from gunk between the fingers and on the back of your hands). 

When your dough is kneaded through, you want to form a good surface for the rising period. You can use flour, oil or water; you'll use so little that it doesn't really matter much. Just spread a thin film on your surface, shape the boule and put it into the rising bowl. 

For the final rise, you want it to keep its shape when it's put into the oven. So, when you are giving it its final shape, you can use either flour or a starch to prevent it from sticking to whatever it is rising on. I knew somebody who swore by rice flour as producing the least stickiness, but use plain wheat flour myself. You can even lay it on a bed of flour; it is not getting pressed into it, so it won't absorb it and get hard. But you will have a layer of either raw or burned flour on the prepared bread. 

An exception would be very oil-rich breads (at least half as much butter as flour). They do better when the final shaping is done in oil too. 

For pastries and cookies, it depends on the type of dough. If it is supposed to be a hard dough, use flour. The strudel mentioned above is made in flour. If it is supposed to be a soft or tender dough, you can try shaping without any smoothening (for example many cookies will flow into a smooth shape during baking even if put onto the sheet as an unsightly pinched ball). Ugly sticky pastry doughs like pie crust can be rolled into submission if you roll them between two smooth silicone mats, but you can't get them very thin that way. If you need them at less than 4 mm, use flour, best in combination with the silicone. Plastic wraps also works, but you might have to use two pieces per surface when the crust gets wide. 

If you have a dough which really feels half-liquid in your hands, shape with flour. Corriher's very light southern biscuits from Cookwise are a good example for such a dough.