Here's the official avenues to buy tickets for every team:
NHL Hockey Tickets
There are also many second hand sellers such as StubHub and SeatGeek. Those two are reputable as far as secondary market websites go. I haven't used Vivid Seats, but they are also a big seller I see a lot.
If you're feeling braver, you can try local Craigslist or Facebook group postings. Even more adventurous, you can buy tickets from individuals right outside the event. I've done all of those before and have never been scammed, but it's possible if you're not careful. The best assurance (and for some teams the only way) is to have someone digitally transfer the tickets to your Ticketmaster account (you'll want to make an account and download the app to your phone).
As for when? That's up to you. Sometimes the longer you wait the better the prices get, as people become more motivated to sell. But if demand spikes, so to will prices. If you're making firm travel plans, sooner is probably better. If you're more go with the flow, there's no harm seeing if you can get a deal.