It seems clear to many scholars which issues belong to philosophy-of-X and which rather belong to X. And sometimes it is indeed obvious when some given issue is for example mathematical or physical and has little to do with philosophizing. But I wonder: are there any rules-of-thumb by which to draw the line between X and philosophy of X? Or is it rather a matter of nearly arbitrary choice?
The general answer, which may admit of exceptions, is that first-order questions belong to the discipline, whereas second-order questions belong to the philosophy of the discipline.
Let's try to cash that distinction out a bit. A question is first-order if it asks which objects have which properties, where the properties are not defined in terms of anything else. Different disciplines are distinguished by the different kinds of first-order properties they investigate. For instance, a first-order question in biology is: "What explains why these different finches have similar, but not identical beaks?"
A second-order question is one which asks about the first-order questions. For instance, "What would it mean for some answer to the question 'What explains why different finches have different beaks' a good answer?"
All such second order questions are philosophical. This doesn't mean that a practicing biologist, for instance, might not occasionally weigh in on such issues. (The boundaries between philosophy and the sciences are porous.)
I find the line, if it exists, tends to depend on the topic. Everything which is part of X is part of X, which means it has to follow all of the rules and ideals X contains. However, most X are not self-verifying. They almost always have some assumptions which cannot be presumed using X's rules and ideals. At that point, the philosophy of X takes over, and starts commenting on why those assumptions were valid and meaningful in the first place.
In the case of science this is easy. Science follows the scientific method, so if you want to see if something is scientific, you look at its method and see if it follows it. However, is the scientific method, itself, scientific? Science can't really answer that question without infinite regress, so the question of the validity of the scientific method for empirical study is in the realm of the philosophy of science.
In the case of religion, this can be more blurry. Religions are often rely on belief for their fundamental axioms, so they have a natural need to explain why those beliefs make sense. We often see overlap between religion and the philosophy of religion, as can be seen by centuries of philosophers defending positions which were staunchly Christian. In these cases, the philosophy of religion often covers the points where religion gets tired of trying to give reasons why or find the level of precision of language distasteful (such as the "if God is omnipotent...").
This answer is very similar in nature to Shane's answer. However, I think Shane's answer works better when there is a clear definition of first-order questions and my answer works better when you may support a few layers of second-order questions within X before turning to philosophy of X for the next layer.