Since B[i] can change depending on some as yet unknown thing (maybe some values of B[1], B[2], B[3],.. will behave differently than others, at this point e don't know maybe it will maybe it won't), let's start off by simplifying, getting rid of the stuff we don't know about and leaving unconditional operations:
j := 1 ---------------------- 1 time while j < n do --------------- n times k := j ------------------- n-1 times for i := j + 1 to n do ----- ? k := i ----------------- ? j := j + 1 ---------------- n-1 times
(This is the point of worst-case analysis, because of the conditional and the data in B, things may go much faster, but at least it'll be no worse than the analysis we're about to do.
The inner loop will occur altogether $n-1$ times (think of it just like the other assignments). But each operation in that inner loop (incrementing the $i$, comparing it to $n$, setting $k$ to $i$) how many times will they take place? Well, from $j+1$ to $n$ times. Which is $n - j - 1$. So as $j$ goes from 1 to $n$, $i$ goes from $j+1$ to $n$. This can be expressed as a summation: $\sum^n_{j=1} \ \sum^n_{i=j+1} ???$ What is the question mark? What is the inner thing being summed? Well, let's be simple, ignore the extra comparisons and additions in the 'for' command' and just count the 'k := i ' assignment or 1 operation. So the summation looks like this: $\sum^n_{j=1} \ \sum^n_{i=j+1} 1.$ Now you should be able to find it easier to manipulate this sum than it is to manipulate the programming language operations. For example, summing 1 from $a$ to $b$ is the same as summing 1 from 0 to $b-a$ which is equal to $b-a+1$ (why the '$+1$'?).
Once you can manipulate the summation, then you can go back to adding in complexities, like multiple assignments. You'll realize that those simplifications I made were not really important,they only change a constant in front of the final answer.
Since for this algorithm (insertion sort), it ends up being dependent on the actual data $B$ being sorted, the worst case is the most exact answer you'll get (you really don't want to worry about the conditional) unless you know something about what $B$ looks like (is it already sorted, in reverse, some interesting subset of permutations, etc.