'Ek' is used whenever you would say 'one' in English.
For example: if someone asks you "kitne aadmee hain?" (How many men are there?) You would say "vahaan ek aadmee hai." (There is one man.) Because you are saying an exact amount of how many men are there. If you are saying a sentence where you are saying the word 'one' in English, you would say 'ek'. But if you are saying a sentence where you are saying the word 'a', you wouldn't need 'ek' in Hindi
'एक' can also be used as an indefinite article in Hindi (in place of 'a'). However, since Hindi doesn't require an article in front of every noun, it is used more sparingly. It is mostly used when you are introducing a new topic or subject and is optional otherwise.
For example, you can start a story this way - बहुत साल पहले एक जंगल था और उस जंगल में एक शेर रहता था। - A long time ago, there was a forest and in that forest, there lived a lion. 'Ek' is not used as 'one' here because there was obviously more than one forest in existence and the forest in question might as well have had more than one lion. Instead it's used because the particular jungle and lion are being spoken about for the first time.
Similarly, when you are introducing yourself to someone, you might say 'मैं एक शिक्षक हूँ।' (I am a teacher). However, when you're mentioning this in the middle of a conversation, you can usually drop the 'ek'. Eg: मैं शिक्षक हूँ और मुझे कल सुबह जल्दी कॉलेज जाना है - I'm a teacher and I have to go to college early tomorrow morning.
Peter is very good boy. Incorrect but english is not my native. I can guess 50 % when is a the or nothing. And i am not learning english here. Peter is very good boy one can syy and Peter is very ugly chair other can say and are both are incorrect but it is obvious who understands hindi!