This quote comes from Shakespeare's excellent tragedy Hamlet, and so I have moved this question to the appropriate group. The quote is uttered by Ophelia in Act I scene 3, and she says this in response to the advice given to her by her brother regarding the intimacy between her and Hamlet. It is clear that Laertes is concerned about Ophelia being used and abused by Hamlet, and now that he is free to return to his studies and leave Elsinore, he is keen to ensure that Ophelia takes steps to protect herself now that he will not be there to protect her from an inappropriate attachment that could lead to her downfall. Thus it is, that after a whole series of lines conveying his concern for her situation, Ophelia responds with the quote you have identified:
I shall th'effect of this good lesson keep,
As watchman to my heart...
Ophelia therefore seems at least overtly to recognise the truth of her brother's admonitions, and agrees to learn the "lesson" that Laertes has just taught her.