When is it not okay to cheap out on bike parts? Cycling is a very expensive hobby. So I tend to buy stuff not from famous brands like FSA and so on. But is it safe to do that? Cheap handlebars will send me flying like Superman one day. What parts of the bike I should never buy cheap?
There are potentially a lot of ins and outs to this question, as one could ask what discipline you're talking about, how aggressive of a rider you are, skill level, etc, as it all has an impact on how likely you are to be punished for going cheap, and how severely. 

However, there's a really good axiom in cycling: "Cheap, light, and strong. Pick two." Your answer is pretty much right there.

An example would be comparing a bottom-end aluminum Shimano road wheelset vs super cheap, unreputable carbon wheels. The former is cheap and strong but not light, and the latter is cheap and light but not strong. For most categories of bike component, there are going to be choices that have a similar relationship. If you want to get by with cheap stuff, this is the angle you have to work. Light components at very low prices, especially ones new to the market, often turn out to be junk, sometimes in a way that can be dangerous (there have been numerous pedals, wheels, hubs, stems, brakes, and cranks in this vein in particular.) Conversely, being really successful at being a thrifty cyclist is usually all about either finding the stuff that's a little less flashy but more stalwart and able to get the job done or just finding good higher end stuff at low prices. Most attempts at "getting away with something" by buying the other kind of cheap stuff are bound to fail.

Some more particulars:


There are a lot of flashy, cheap two-piece cranks running around these days that can have issues with pressed interfaces that are supposed to be permanent coming apart and creaking.
There are some good offbrand carbon rims and some that have proved unreliable. It's a good place to be cautious.
Rear hubs are a component where it's easy for manufacturers to put out something for cheap that has a high engagement rate, smooth bearings, and light weight that then proceeds to totally fail to be a reliable component. It's best to go for something that's either a known workhorse (XT and 105 for example) or true high end, and not roll the dice on anything else.
Cheap, off-brand headsets and bottom brackets are almost always disappointments.


A final note: it's actually a really good idea to pay close attention to how long a given model of component has been on the market unchanged. Bike component manufacturers love having flashy new attention-getting things and often feel pressure to change up their lines at least every couple years if not sooner. More often than not, when they keep the same model kicking around longer than this it's because it's just a good design and has earned a reputation for it, and there are a lot of examples of cheaper components this applies to. PD-M520s, CR18s, and FH-M756s are some examples from the last couple decades.