Remember that 'have' and 'have got' are only interchangeable in the PRESENT SIMPLE. So, you can say either 'I have a headache' or 'I've got a headache' in the present tense, and the meaning is the same.
This doesn't work in other tenses. The past simple of 'He has a headache' is simply 'He had a headache'. The future is 'He'll have a headache'. You cannot use the alternative form with 'got' in any tenses other than the present.
The form 'had got' exists in British English as the past perfect of the verb 'to get'. This has nothing to do with 'have got' meaning possession, used as an alternative to 'had'. In sentences using 'had got', the verb 'to get' is the main verb, meaning to arrive, to become, or to obtain. For example:
By 11 pm I had got very tired, so I went to bed = 'I had become very tired'
We didn't need to buy food because I'd got some at the supermarket the day before = 'I had bought some'
NB In American English, this would be 'gotten', rather than 'got'.
'You had got an idea' means 'You had had an idea' or 'An idea had entered your head' in the past perfect. This is a different tense from 'You had an idea' in the past simple.
And in fact, you can say 'He had got a headache', but this is not the past of 'He has got a headache'. It is the British English past perfect of 'He gets (acquires) a headache'.
This is quite subtle and potentially confusing. My best advice to you is as I said at the beginning - only use 'have got' as an alternative 'have' in the PRESENT SIMPLE.