I have noticed from different published articles that mathematical equations may or may not be ended by a comma or a period (depending on their position in the text). Which is the best practice?
The best practice is to follow the style guidelines of the publication you are writing for. An editor will make sure that your manuscript fits within the style guidelines of the publisher. If there are no specific guidelines for your case or you aren't writing for a specific audience, do whatever seems right to you. Just make sure that your adopted style is clear and consistent, and be ready to defend it if necessary.
Personally, I think that punctuation can be unsightly and confusing in displayed math, but is usually helpful for clarity of inline math. This is one of my few points of disagreement with Chicago, whose chapter 12 advocates punctuating all displayed and inline math as integral to its containing sentence.
Yes it is good practice. You should read the papers of people are well known to be excellent expositors like Serre and his students Atiyah and Grothendieck (who also had quite a few students). They all endorse commas and periods. Perhaps the best guide to mathematical writing is https://www.youtube.com/watch?v=ECQyFzzBHlo (Serre). Let me emphasize how authoritative Serre's opinion is: he is easily the most influential mathematician of the postwar period.