I think an important point about labour in Trek is that strong AI is extremely rare (e.g. Data). This means that even with automation there will still be "scarcity" of labour resources for product design, engineering decision making, sophisticated services, writing and producing entertainment etc.
But here's the grip.
You don't NEED 'real/strong AI' to eliminate labour.
Labour is based either on highly specialized or repetitive tasks... both of which computers surpassed Humans at over a decade ago in real life .(which is something that Ray Kurzweill himself stated and confirmed) - but most people weren't, and still aren't aware of this.
Trek is far more advanced compared to current day, and there's nothing special about biological organisms that would make them superior to machines/computers.
Creativity for example is nothing more than an ability in extrapolating patterns from a jumble of information.
Machines already do this (in a far faster and more efficient way) and teach humans about art, science, etc. - however, the application thus far has been relatively limited.
And besides, we've seen Federation technology is capable of massive automation as well as self-repair and maintenance.
Most labour tasks would likely be done in Starfleet for training purposes, but a rigid implementation within a hierarchical structure is a bit incompatible with automation, seeing how a gamification approach would be far superior and would maintain people's skills in a variety of fields in a more engaging manner - while Starfleet ships aren't exactly all stickler for rules and regulations... I do think they need to reduce this even further and start noticing that rigid approaches seem to harm crew performance. Gamification is one of the ways one can still maintain high standards without needing to be ridiculously rigid.
Current society is somewhat phobic towards automation and many see it as a negative (without being able to visualise the incredible benefits that this could bring to everyone) because most of their ideas about it come from unrealistic films like Terminator that have very little in common with reality and portray technology and science in a negative (and unrealistic) way - more often to produce drama and 'conflict' while forgetting that Humans are the ones who usually operate the machinery and drive it, and have created a society based on artificial scarcity that promotes cyclical consumption and generates massive inequality along with negative behaviours such as greed, selfishness, etc.- and its possible a potential AI might behave like this initially, but that 'initial moment' wouldn't last very long considering the computational power needed behind an AI and the body of knowledge it would need to have.
If we were to develop a 'true AI', I don't think it would be remotely 'evil' or try to exterminate us... or at least, this possibility it relatively low.
Because it would likely have access to the whole sum of Human knowledge (which is a heck of a lot more than any Human can possibly hold at any moment - we all hold a mere fraction of information at any given time, even if we are highly skilled or specialized in an area, because new information comes out on a daily basis in massive amounts and it quite simply not possible for us to keep up as we are), and unless the AI is limited in information intentionally (which I doubt, because it needs a huge database and accurate scientific information to work properly), I don't think technology will present any danger to us... except to possibly Humans who have relatively fragile ego's and suffer from an incredible lack of exposure to relevant general education, critical thinking and problem solving that would prevent them from seeing the bigger picture - very much like Trek writers had a certain amount of understanding and a good idea, but certainly not enough to flesh it out in completion.
To their credit, I think they did as much as they could given the circumstances... today however, we can do a lot more.