The condition for effective planning of advertising is the use of scientific methods of placement of advertisements. The use of quantitative methods of media planning increases the effectiveness of advertising exposure. The problem of evaluation of effectiveness of advertising has not yet been solved. The effectiveness of advertising depends on two factors: the creative concept of advertising message and optimization of placement of advertisements. The most thoroughly investigated questions are the questions of efficiency of influence of advertising messages on the audience. Quite often the role of the second of these factors is underestimated. In this regard, the development of analytic theory of media planning is very important. The use of theory of media planning increases the effectiveness of advertising. In this paper an economic-mathematical theory of media planning is developed. Within the framework of this theory the concept of risk of advertising in the media is defined, technique for its calculation is provided, the problem of optimization of placement of advertisements is solved. The dependences of the risk of placement of advertisements on their number and on the magnitude of the advertising budget are calculated. Risk calculations are carried out using both analytical and numerical methods. The results obtained can be used in the planning of the actual advertising campaigns.