Greg's code always gives you the above Heading 1 text. If you wanted the nearest preceding heading of any level the code could be
Code:
Sub ScratchMacro()
Dim oTbl As Table, oRng As Range, rngHead As Range, strTitle As String
For Each oTbl In ActiveDocument.Tables
Set oRng = oTbl.Range
Set rngHead = oRng.GoTo(What:=wdGoToHeading, Which:=wdGoToPrevious, Count:=1).Paragraphs(1).Range
rngHead.MoveEnd Unit:=wdCharacter, Count:=-1
strTitle = rngHead.Text
oTbl.Range.InsertCaption Label:="Table", Title:=" - " & strTitle, Position:=wdCaptionPositionAbove, ExcludeLabel:=0
Next
End Sub