This is useful advice which Allah tells us Luqman gave, so that people may follow it and take it as a good example.
He said;
يَا بُنَيَّ إِنَّهَا إِن تَكُ مِثْقَالَ حَبَّةٍ مِّنْ خَرْدَلٍ
O my son!
If it be (anything) equal to the weight of a grain of mustard seed,
means, if a wrong action or a sin be equal to the size of a grain of mustard seed.
...
فَتَكُن فِي صَخْرَةٍ أَوْ فِي السَّمَاوَاتِ أَوْ فِي الاَْرْضِ
and though it be in a rock, or in the heavens or on the earth, Allah will bring it forth.
...
يَأْتِ بِهَا اللَّهُ
Allah will bring it forth.
means, He will bring it forth on the Day of Resurrection, when it is placed in the Scales of justice and everyone is rewarded or punished for his actions -- if they are good, he will be rewarded and if they are bad he will be punished.
This is like the Ayat;
وَنَضَعُ الْمَوَزِينَ الْقِسْطَ لِيَوْمِ الْقِيَـمَةِ فَلَ تُظْلَمُ نَفْسٌ شَيْياً
And We shall set up Balances of justice on the Day of Resurrection, then none will be dealt with unjustly in anything. (21;47)
فَمَن يَعْمَلْ مِثْقَالَ ذَرَّةٍ خَيْراً يَرَهُ
وَمَن يَعْـمَلْ مِثْقَالَ ذَرَّةٍ شَرّاً يَرَهُ
So, whosoever does good equal to the weight of a speck of dust shall see it. And whosoever does evil equal to the weight of a speck of dust shall see it. (99;7-8)
Even if this tiny thing were to be hidden inside a solid rock or anywhere in the heavens and the earth, Allah will bring it forth, because nothing is hidden from Him, not even the weight of a speck of dust in the heavens or on the earth.
Allah says;
...
إِنَّ اللَّهَ لَطِيفٌ خَبِيرٌ
Verily, Allah is Subtle, Well-Aware.
meaning, His knowledge is subtle, for nothing is hidden from Him, no matter how small, subtle and minute.
خَبِيرٌ
(Well-Aware), even of the footsteps of an ant in the darkest night.
Then he (Luqman) said;