Dyalog APL 16.0APL (Dyalog Unicode), 43 37 bytes28 bytes
Full program. Prompts for comment charactercode, then for codecomment character.
↑(↓↑((-(⍸'|'∘=)⍞,≢)↑¨'|'∘≠⊆⊢⍤1⍨⎕FMT⎕TC[2]@('|'∘=)⍞),¨⊂¯2↑⍞' '
⍞,' '
append a space the to prompted-for code
⎕TC[2]@(
…)
place the 2nd Terminal Control character (Line Feed) at the positions indicated by:
'|'∘=
the mask indicating where the pipe symbol is equal to the characters
⎕FMT
ForMaT as a character matrix, evaluating terminal control characters (Line Feed moves the "cursor" down one line)
⍞,⍤1⍨
prompt for comment character and append it to each line (lit. to each 1D sub-array)