The comma is used for setting off nonessential explanations. If an explanation or definition occurs as an appositive it should be set off with commas:
When the nonessential explanation is not at the end of the sentence, like in your example, it should be set off with a pair of commas.
If the nonessential explanation is placed at the end of the sentence then only one comma is needed.
The majority of the words that you have written in bold are a type of adverbial (a type of adverb) which is called an disjunct. (whether they are all disjuncts could be argued.).
.Disjuncts allow the speaker/writer to influence the hearer or reader.. They represent the speaker's attitude about what he is going to say.
Here are some examples where the adjunct is written in bold:
Naturally, you are going to go you. = the speaker is certain you will go.
Obviously,I agree with the president. = Its obvious that the speaker will agree.
Of course, she is late. = I think it is to be expected.
Regrettably, he didn't attend the meeting.= I think its sad or too bad that he didn't come.
Surely, you are going to go to school today. = a strong sense of persuasion.
Frankly, I couldn't care less about comma rules. = the speaker really doesn't care.
In each case we use a comma to separate the emotion or attitude of the speaker from the rest of the sentence. Some authorities believe that a comma should be used if the disjunct doesn't flow with the rest of the sentence and in most cases disjuncts are separated by a comma.
There are no hard and fast rules about comma use. and convention plays a role in determining some rules. You learn from experience and even English teachers can get it wrong.
Source Grammar 33 manual U of Saskatchewan, Longman's Dictionary, Guide to Grammar Writing by Charles Darling.
Best Answer
Both are good, although I think the second examples are slightly better. What you are saying is :
Then (by doing this thing) this happens
Now (after selecting this option) this happens
By doing this (now) we can do this