This problem affects every society, including capitalism of course. Under capitalism, this problem is "solved" by ensuring that such jobs are done by those at the bottom of the social pile. In other words, it does not really solve the problem at all — it just ensures that some people are subject to this work the bulk of their working lives. However, most anarchists reject this flawed solution in favour of something better, one that shares the good with the bad and so ensure everyone's life is better.
How this would be done depends on the kind of libertarian community you are a member of. Obviously, few would argue against the idea that individuals will voluntarily work at things they enjoyed doing. However there are some jobs that few, if any, would enjoy (for example, collecting rubbish, processing sewage, dangerous work, etc.). So how would an anarchist society deal with it?
It will be clear what is considered unpleasant work in any society — few people (if any) will volunteer to do it. As in any advanced society, communities and syndicates who required extra help would inform others of their need by the various form of media that existed. In addition, it would be likely that each community would have a "division of activity" syndicate whose work would be to distribute information about these posts and to which members of a community would go to discover what placements existed for the line of "work" they were interested in. So we have a means by which syndicates and communes can ask for new hands and the means by which individuals can discover these placements. Obviously, some work will still require qualifications and that will be taken into account when syndicates and communes "advertise" for help.
For "work" placements in which supply exceeded demand, it would be easy to arrange a work share scheme to ensure that most people get a chance to do that kind of work (see below for a discussion of what could happen if the numbers applying for a certain form of work were too high for this to work). When such placements are marked by an excess of demand by supply, its obvious that the activity in question is not viewed as pleasant or desirable. Until such time as it can be automated away, a free society will have to encourage people to volunteer for "work" placements they do not particularly want to do.
So, it is obvious that not all "jobs" are equal in interest or enjoyment. It is sometimes argued that people would start to join or form syndicates which are involved in more fun activities. By this process excess workers would be found in the more enjoyable "jobs" while the boring and dangerous ones would suffer from a scarcity of willing workers. Hence, so the argument goes, a socialist society would have to force people to do certain jobs and so that requires a state. Obviously, this argument ignores the fact that under capitalism usually it is the boring, dangerous work which is the least well paid with the worse working conditions. In addition, this argument ignores the fact that under workers self-management boring, dangerous work would be minimised and transformed as much as possible. Only under capitalist hierarchy are people in no position to improve the quality of their work and working environment. As George Barrett argues:
"Now things are so strangely organised at present that it is just the dirty and disagreeable work that men will do cheaply, and consequently there is no great rush to invent machines to take their place. In a free society, on the other hand, it is clear that the disagreeable work will be one of the first things that machinery will be called upon to eliminate. It is quite fair to argue, therefore, that the disagreeable work will, to a large extent, disappear in a state of anarchism." [Objections to Anarchism]
Moreover, most anarchists would think that the argument that there would be a flood of workers taking up "easy" work placements is abstract and ignores the dynamics of a real society. While many individuals would try to create new productive syndicates in order to express themselves in innovative work outwith the existing research and development going on within existing syndicates, the idea that the majority of individuals would leave their current work at a drop of a hat is crazy. A workplace is a community and part of a community and people would value the links they have with their fellow workers. As such they would be aware of the impacts of their decisions on both themselves and society as a whole. So, while we would expect a turnover of workers between syndicates, the mass transfers claimed in this argument are unlikely. Most workers who did want to try their hand at new work would apply for work places at syndicates that required new people, not create their own ones. Because of this, work transfers would be moderate and easily handled.
However, the possibility of mass desertions does exist and so must be addressed. So how would a libertarian socialist society deal with a majority of its workers deciding to all do interesting work, leaving the boring and/or dangerous work undone? It, of course, depends on the type of anarchism in question and is directly related to the question of who will do the "dirty work" in an anarchist society. So, how will an anarchist society ensure that individual preferences for certain types of work matches the requirements of social demand for labour?
Under mutualism, those who desired a certain form of work done would reach an agreement with a workers or a co-operative and pay them to do the work in question. Individuals would form co-operatives with each co-operative would have to find its place on the market and so this would ensure that work was spread across society as required. Individuals desiring to form a new co-operative would either provide their own start up credit or arrange a interest free loan from a mutual bank. However, this could lead to some people doing unpleasant work all the time and so is hardly a solution. As in capitalism, we may see some people doing terrible work because it is better than no work at all. This is a solution few anarchists would support.
In a collectivist or communist anarchist society, such an outcome would be avoided by sharing such tasks as fairly as possible between a community's members. For example, by allocating a few days a month to all fit members of a community to do work which no one volunteers to do, it would soon be done. In this way, every one shares in the unpleasant as well as pleasant tasks (and, of course, minimises the time any one individual has to spend on it). Or, for tasks which very popular, individuals would also have to do unpleasant tasks as well. In this way, popular and unpopular tasks would balance each other out.
Another possible solution could be to follow the ideas of Josiah Warren and take into account the undesirability of the work when considering the level of labour notes received or communal hours worked. In other words, in a collectivist society the individuals who do unpleasant work may be "rewarded" (along with social esteem) with a slightly higher pay — the number of labour notes, for example, for such work would be a multiple of the standard amount, the actual figure being related to how much supply exceeds demand (in a communist society, a similar solution could be possible, with the number of necessary hours required by an individual being reduced by an amount that corresponds to the undesirability of the work involved). The actual levels of "reward" would be determined by agreements between the syndicates.
To be more precise, in a collectivist society, individuals would either use their own savings and/or arrange loans of community labour banks for credit in order to start up a new syndicate. This will obviously restrict the number of new syndicates being formed. In the case of individuals joining existing syndicates, the labour value of the work done would be related to the number of people interested in doing that work. For example, if a given type of work has 50% more people wanting to do it than actually required, then the labour value for one hours work in this industry would correspondingly be less than one hour. If fewer people applied than required, then the labour value would increase, as would holiday time, etc.
In this way, "supply and demand" for workers would soon approximate each other. In addition, a collectivist society would be better placed than the current system to ensure work-sharing and other methods to spread unpleasant and pleasant tasks equally around society due to its organs of self-management and the rising social awareness via participation and debate within those organs.
A communist-anarchist society's solution would be similar to the collectivist one. There would still be basic agreements between its members for work done and so for work placements with excess supply of workers the amount of hours necessary to meet the confederations agreed minimum would correspondingly increase. For example, an industry with 100% excess supply of volunteers would see its minimum requirement increase from (say) 20 hours a week to 30 hours. An industry with less applicants than required would see the number of required hours of "work" decrease, plus increases in holiday time and so on. As G.D.H. Cole argues in respect of this point:
"Let us first by the fullest application of machinery and scientific methods eliminate or reduce . . . 'dirty work' that admit to such treatment. This has never been tried. . . under capitalism. . . It is cheaper to exploit and ruin human beings. . . Secondly, let us see what forms of 'dirty work' we can do without . . . [and] if any form of work is not only unpleasant but degrading, we will do without it, whatever the cost. No human being ought to be allowed or compelled to do work that degrades. Thirdly, for what dull or unpleasant work remains, let us offer whatever special conditions are required to attract the necessary workers, not in higher pay, but in shorter hours, holidays extending over six months in the year, conditions attractive enough to men who have other uses for their time or attention to being the requisite number to undertake it voluntarily." [Guild Socialism Restated, p. 76]
By these methods a balance between industrial sectors would be achieved as individuals would balance their desire for interesting work with their desires for free time. Over time, by using the power of appropriate technology, even such time keeping would be minimised or even got eliminated as society developed freely.
And it is important to remember that the means of production required by new syndicates do not fall from the sky. Other members of society will have to work to produce the required goods. Therefore it is likely that the syndicates and communes would agree that only a certain (maximum) percentage of production would be allocated to start-up syndicates (as opposed to increasing the resources of existing confederations). Such a figure would obviously be revised periodically in order to take into account changing circumstances. Members of the community who decide to form syndicates for new productive tasks or syndicates which do the same work but are independent of existing confederations would have to get the agreement of other workers to supply them with the necessary means of production (just as today they have to get the agreement of a bank to receive the necessary credit to start a new business). By budgeting the amounts available, a free society can ensure that individual desires for specific kinds of work can be matched with the requirements of society for useful production.
And we must point out (just to make sure we are not misunderstood) that there will be no group of "planners" deciding which applications for resources get accepted. Instead, individuals and associations would apply to different production units for resources, whose workers in turn decide whether to produce the goods requested. If it is within the syndicate's agreed budget then it is likely that they will produce the required materials. In this way, a communist-anarchist society will ensure the maximum amount of economic freedom to start new syndicates and join existing ones plus ensure that social production does not suffer in the process.
Of course, no system is perfect — we are sure that not everyone will be able to do the work they enjoy the most (this is also the case under capitalism, we may add). In an anarchist society every method of ensuring that individuals pursue the work they are interested in would be investigated. If a possible solution can be found, we are sure that it will. What a free society would make sure of was that neither the capitalist market redeveloped (which ensures that the majority are marginalised into wage slavery) or a state socialist "labour army" type allocation process developed (which would ensure that free socialism did not remain free or socialist for long).
In this manner, anarchism will be able to ensure the principle of voluntary labour and free association as well as making sure that unpleasant and unwanted "work" is done. Moreover, most anarchists are sure that in a free society such requirements to encourage people to volunteer for unpleasant work will disappear over time as feelings of mutual aid and solidarity become more and more common place. Indeed, it is likely that people will gain respect for doing jobs that others might find unpleasant and so it might become "glamorous" to do such activity. Showing off to friends can be a powerful stimulus in doing any activity. So anarchists would agree with Albert and Hahnel when they say that:
"In a society that makes every effort to depreciate the esteem that derives from anything other than conspicuous consumption, it is not surprising that great income differentials are seen as necessary to induce effort. But to assume that only conspicuous consumption can motivate people because under capitalism we have strained to make it so is unwarranted. There is plenty of evidence that people can be moved to great sacrifices for reasons other than a desire for personal wealth...there is good reason to believe that for nonpathological people wealth is generally coveted only as a means of attaining other ends such as economic security, comfort, social esteem, respect, status, or power." [The Political Economy of Participatory Economics, p. 52]
We should note here that the education syndicates would obviously take into account the trends in "work" placement requirements when deciding upon the structure of their classes. In this way, education would respond to the needs of society as well as the needs of the individual (as would any productive syndicate).