the plugin needs to run in POST operation (usually synchronous) otherwise you will not have the ID of the membership you just created.
Inside the plugin you read the Contact (I suppose there is a lookup pointing to Contact inside Membership) and after you create a new MemberDetails record filling the two lookups (one pointing to Membership with the ID you got and the other to Contact)
Maybe this can be done also with a classic workflow but I usually write plugins in this scenario.
hope it helps