Exercise can affect BG for 48 hours afterwards and overall results in a lowering of BG although you may see a rise during or immediately afterwards.
Generally, (although we are all different), cardio will see an immediate drop and resistance or HIIT will see a rise. I use this variance as a way to temper my BG during a gym session - if my levels are higher than I would like, I start with cardio and, if they are lower, I start with weights.
There are a couple of things that happen when we exercise, as mentioned above, our liver dumps glucose to give us energy. Our body becomes more efficient at using insulin (I think it is the muscles that use the insulin but I could be wrong with that). Due to the liver dump, if you do a longer activity, the liver will need a top up which is why BG can be lower for a couple of days after.
So, when to test your levels? Definitely before and when you finish but also a few hours later.