It probably makes more sense to use ranges e.g. as follows, then you don't have to open and close the header.
Your selection from the end of the document only selects 2 'lines'.
Sub Macro1()
Dim oRng As Range
Dim oHeader As HeaderFooter
Selection.EndKey Unit:=wdStory
Selection.MoveUp Unit:=wdLine, Count:=3, Extend:=wdExtend
Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
Set oRng = Selection.Range
Set oHeader = oRng.Sections(1).Headers(wdHeaderFooterPrimary)
oHeader.Range.FormattedText = oRng.FormattedText
oRng.Text = ""
Set oRng = Nothing
Set oHeader = Nothing
End Sub
Note 'lines' are a vague concept in Word as they are volatile and created by text flow. They don't actually exist. If however you mean paragraphs rather than lines then
Sub Macro2()
Dim oRng As Range
Dim oHeader As HeaderFooter
Set oRng = ActiveDocument.Range
oRng.Collapse 0
oRng.MoveStart wdParagraph, -3
Set oHeader = oRng.Sections(1).Headers(wdHeaderFooterPrimary)
oHeader.Range.FormattedText = oRng.FormattedText
oRng.Text = ""
Set oRng = Nothing
Set oHeader = Nothing
End Sub