What correlations exist, if any, between a country's age distribution and its economic output? Additionally, does the relative shape of a country's population pyramid seem to give any indication of future performance in (a sector of) the stock market? I have read that a country with an age distribution like an inverted pyramid (more older people than young people) requires a greater investment in healthcare, and the opposite shape (non-inverted pyramid) requires a greater investment in education. Therefore, is it a stretch to conclude that the healthcare sector in a country with an inverted pyramid age distribution will fair better than it would with a non-inverted pyramid in the same country?
Also, is there a name for the sub-field of economics that studies how demographics is related to economy?
The question of how demographics relate to economic issues (e.g., poverty, economic growth) has been at the forefront of economics ever since its infancy as a science. For instance, Rev. Malthus (1766-1834) controversially suggested that population growth would erase any improvements in the standard of living due to technological advances. At present, various aspects of the question of how demographics affect (and are affected by) the economy are studied by many fields of economics. There isn't one single field that does it all. For example, a macroeconomist may be interested in the relationship between population growth and growth in real GDP per capita. A labor economist may investigate how family structure influences an adult's time allocation across childcare, eldercare, market work, etc. A health economist may study how local population composition impacts the demand for long-term care facilities. I trust you'll come up with examples in other fields, say, environmental economics.
Individuals of different ages in a given country tend to demand different bundles of goods and services. (You provided a nice example involving healthcare and education.) As a result, countries with different population compositions (but similar in other respects) will allocate their resources differently and, therefore, the composition of their GDPs will differ as well. For examples, a country with few children of school age is likely to invest relatively little into new school construction (and spend little on teacher salaries). This and similar examples can provide the correlations you are looking for. I am not aware of a universally accepted, single list of such correlations, however.
As far as the *future* size of a particular sector of the economy is concerned, the *current* shape of the population pyramid might be a good predictor under some circumstances. However, you would generally want to know the pyramid's *future* shape, which may be difficult to predict accurately. (Much depends on how far you are looking into the future, of course.) Regarding the sector's future profitability and stock market performance, there are other important factors at play, including barriers to entry and government regulation, particularly in the case of such heavily regulated sector as healthcare. Given a Medicare-like system in place, an inverted pyramid implies that relatively more health service payments could be negotiated by the government (rather than private insurers), which might lead to lower profits for healthcare providers. Thus, I do not take your conclusion as a given.