Concatenate fields in a view with comma when values may be empty
I would actually suggest doing the reverse of the answered question that you linked to for just the scenario you are describing.


Add Field B and Exclude it from the display.
In the Rewrite results area of Field B, enable Rewrite the output of this field. 
On Field B, add a comma and the token for the raw value: ', [field-b]'
Under 'No Results Behavior' for Field B, make sure that 'Hide if empty' and 'Hide rewriting if empty' are checked.
Then rewrite your Field A to include Field B: '[field-a][field-b]'. Make sure there is no space, so that the comma will immediately follow Field A if Field B has a value.