When (if ever) is it a good idea to do a post hoc power analysis? My understanding is that a power analysis is post hoc if and only if it uses the observed effect size as the target population effect size.
 A: In my field I see people doing post-hoc power analyses when the purpose of the paper is to show that some effect that one might have expected to be present (either because of previous literature, common sense, etc) is not, at least according to some significance test.
However, in these situations, the researcher is in a bit of a bind -- he or she may have obtained a non-significant result either because the effect really is not present in the population or because the study was not sufficiently powered to detect the effect even if it were present.  The purpose of the power analysis, then, is to show that, given even a trivially small effect in the population, the study would have had a high probability of detecting that effect.
For a concrete example of this use of post-hoc power analysis, see this linked paper.
A: You can always compute the probability that a study would have produce a significant result for a given a priori effect size.  In theory, this should be done before a study is conducted because there is no point in carrying out a study with low power that has a low chance to produce a significant result when an effect is present.  However, you can also compute power after the study to realize that a study had low power or, unlikely, high power to detect even a small effect. 
The term post-hoc or observed power is used for power-analysis that use observed effect sizes in a sample to compute power under the assumption that the observed effect size is a reasonable estimate of the true effect size. Many statisticians have pointed out that observed power in a single study is not very informative because effect sizes are not estimated with sufficient precision to be informative. More recently, researchers have started to examine observed power for a set of studies to examine how powerful studies are on average and whether studies report more significant results than the actual power of studies would justify. 
https://replicationindex.wordpress.com/tag/observed-power/
