There's a reason so many recipes say "salt to taste": there's no single answer. Most of the time, we use close to 0.5% salt by weight (so 1kg food has 5g or 1 teaspoon of salt), but "close to" leaves plenty of wiggle room about what exactly is best.
Different people have different tastes. What's perfectly salted for one person may be oversalted or undersalted for another.
Different dishes need different ratios too. Some things are supposed to taste a bit salty, while some just need a hint to amplify other flavors. Some ingredients need more salt to balance them than others.
Sure, you can get approximate starting points, e.g. bread might be around 1% salt by weight, cookie dough might be about 0.5%, soups and stews might be something like 0.5% (with tons of variation - that's a couple random recipes). So very roughly, 1kg of food often comes with 5 grams of salt (1 teaspoon) with exceptions ranging up to 10 grams (2 teaspoons).
But your best bet is always going to be to find a good recipe for the specific dish you're making, and possibly adjust it if you know your preferences lean one way or another. Failing that, when cooking something improvised or new, or using one of the many recipes that just says "salt to taste", letting you do what suits you, trust the instincts that you've developed for your own tastes.
If you're cooking for others, with possibly varying tastes, it gets trickier. For things where salt can be added after the fact, you can use less salt and let everyone individually salt to taste. For things you can't mix after cooking, you pretty much have to compromise somewhere in the middle and hope it works for everyone.
Beyond that, if you can't decide what the right amount of salt is, don't worry about it. There's surely a range that works for you, so if two different amounts both taste good, there you are. And if you find yourself disagreeing with someone about what amount of salt results in the best flavor, stop. You probably just have different tastes from the person you're arguing with.