Habeas corpus derives from the English common law where the first recorded usage was in 1305, in the reign of King Edward I of England. The procedure for the issuing of writs of habeas corpus was first codified by the Habeas Corpus Act 1679, following judicial rulings which had restricted the effectiveness of the writ. A previous act had been passed in 1640 to overturn a ruling that the command of the Queen was a sufficient answer to a petition of habeas corpus. Winston Churchill, in his chapter on the English Common Law in The Birth of Britain, explains the process thus:

Based on this passage, when was the writ of habeas corpus created? Let's give stream of consciousness first:
The relevant sentence in the passage is: The procedure for the issuing of writs of habeas corpus was first codified by the Habeas Corpus Act 1679, following judicial rulings which had restricted the effectiveness of the writ.
So, the final answer is 1679.